Created
May 4, 2021 23:38
-
-
Save retorquere/c8d125e083d2a1222c3e73fd0639205c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# run as ris.py importdir1 importdir2 ... | |
import glob, sys, os, re | |
ris = '' | |
for importdir in sys.argv[1:]: | |
for pdf in glob.glob(os.path.join(importdir, '*.pdf')): | |
m = re.match(r'^(.+?)@(.+?)\$(.+?).pdf$', os.path.basename(pdf)) | |
if m: | |
title, author, year = [g.strip() for g in m.groups()] | |
ris += 'TY - JOUR\n' | |
ris += 'TI - ' + title + '\n' | |
ris += 'AU - ' + author + '\n' | |
ris += 'DA - ' + year + '///\n' | |
ris += 'PY - ' + year + '\n' | |
ris += 'L1 - ' + pdf + '\n' | |
ris += 'ER -\n' | |
ris += '\n' | |
print(ris) # or write it to a file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment