I finally managed to get this to work using the sed command line in my Mac terminal. I needed to do this for the RIS file import from Zotero, which has file attachments as “file/(a number)/(file name).pdf”
“/localhost/Users/(me)/Documents/RIS/file/” is the directory under which I consolidated the pdf.
Below is the code I used:
#To check it works
#for the first file attachment: replaced " files/…" with “_files/…” so the space doesn’t get replaced with “%20”.
sed -e ‘s/ files//_file://localhost/Users/(me)/Documents/RIS/file//g’ Endnote_export_file.txt | more
#for records with more than one file attachment.
sed -e ‘s/^files//file://localhost/Users/(me)/Documents/RIS/file//g’ Endnote_export_file.txt | more
sed -e ‘s/ files//_file://localhost/Users/(me)/Documents/RIS/file//g’ Endnote_export_file.txt > file1.txt
sed -e ‘s/^files//file://localhost/Users/(me)/Documents/RIS/file//g’ file1.txt > file2.txt
#replace " " with “%20” for file attachment links
sed -e ‘/file:/s/ /%20/g’ file2.txt | more
sed -e ‘/file:/s/ /%20/g’ file2.txt > file3.txt
#replace “_file:” with " file:" for the first file attachment
sed -e ‘s/_file:/ file:/g’ file3.txt | more
sed -e ‘s/_file:/ file:/g’ file3.txt > file4.txt
Then import file4.txt using Endnote import filter.
HIH!