Importing files with structured filenames: "title @author $year.pdf"
Hello community. I have a large collection of PDFs, some of them which I scanned myself (I'm a historian and we often use old articles). All of them are in the format "title @author $year.pdf" for easy look up through Spotlight/Alfred. Is it possible to take advantage of this naming system and import them as partly-formatted items (with title, year and last name of the author) to Zotero together with the original PDF as attachments? Presumably something similar to what https://github.com/retorquere/zotero-folder-import does, but with filenames instead of a folder structure.
L1
line.TY - JOUR
L1 - ~/Users/myfolder/title authors year.pdf
AU - author
TI - title
PY - year
ER -
dir /a-d /b /s
for you, but that's really for a one-shot)No worries.
Once that is in place, let's say that your PDFs live at
Documents/My Academic stuff/very important
andDocuments/My Academic stuff/frivolous
:Documents/My Academic stuff
with finder and use "New terminal at folder". The terminal will pop up. Without the finder services you can also cmd-space, type "terminal", and then typecd '~/Documents/My Academic stuff'
, which will achieve the same.python ~/Downloads/ris.py 'very important' frivolous
Documents/My Academic stuff/very important/very important.ris
andDocuments/My Academic stuff/frivolous/frivolous.ris
which you can import.You can add paths to folders of PDFs as you please, or run it one folder at a time. The outcome will be the same.
SyntaxError: Non-ASCII character '\xc2' in file /Users/jakub/Downloads/ris.py on line 11, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
How does one declare encoding? If it's complicated, I can batch-change all ® to $.
(you can define utf-8 encoding by putting
# -*- coding: utf-8 -*-
or
# coding: utf-8
in the 2nd line of the script, but I don't think that should be necessary)
(the \ before the $ sign is an "escape" character, because $ is a special character. It's not needed for ®. If it doesn't run after this, add the
# coding: utf-8
line.