├── .gitignore ├── Import PDFs from Zotero.applescript └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/macos 3 | # Edit at https://www.gitignore.io/?templates=macos 4 | 5 | ### macOS ### 6 | # General 7 | .DS_Store 8 | .AppleDouble 9 | .LSOverride 10 | 11 | # Icon must end with two \r 12 | Icon 13 | 14 | # Thumbnails 15 | ._* 16 | 17 | # Files that might appear in the root of a volume 18 | .DocumentRevisions-V100 19 | .fseventsd 20 | .Spotlight-V100 21 | .TemporaryItems 22 | .Trashes 23 | .VolumeIcon.icns 24 | .com.apple.timemachine.donotpresent 25 | 26 | # Directories potentially created on remote AFP share 27 | .AppleDB 28 | .AppleDesktop 29 | Network Trash Folder 30 | Temporary Items 31 | .apdisk 32 | 33 | # End of https://www.gitignore.io/api/macos 34 | -------------------------------------------------------------------------------- /Import PDFs from Zotero.applescript: -------------------------------------------------------------------------------- 1 | set ZoteroFolder to POSIX file "/path/to/zotero/storage" 2 | set ComparisonDatabase to "your_paper_database" 3 | 4 | tell application "Finder" 5 | 6 | # iterate over all subfolders of ZoteroFolder 7 | repeat with RandomFolder in (get every folder of folder ZoteroFolder) 8 | # iterate over all files within the subfolder 9 | repeat with PaperFile in (get every file of folder (RandomFolder as alias)) 10 | 11 | # store the Posix path of the file for import with Devonthink 12 | set PosixPaperFile to POSIX path of (PaperFile as alias) 13 | 14 | # check if the file contains '.pdf' 15 | if (PaperFile as string) contains ".pdf" then 16 | 17 | tell application "DEVONthink 3" 18 | # import file from Posix path 19 | set ImportedFile to (import PosixPaperFile to current group) 20 | 21 | # get list of similar files 22 | set SimilarFiles to compare record ImportedFile 23 | 24 | # iterate over similar files 25 | repeat with Similar in SimilarFiles 26 | 27 | # SimilarFiles contains the added file itself (score is 1.0) 28 | # skip the added file itself (identified by the record ID) 29 | if id of Similar is not equal to id of ImportedFile then 30 | 31 | # if there is at least one record with very high similarity 32 | # we delete the file we just added and break 33 | if score of Similar is greater than 0.95 then 34 | delete record ImportedFile 35 | exit repeat 36 | end if 37 | end if 38 | end repeat 39 | 40 | end tell 41 | 42 | end if 43 | 44 | end repeat 45 | 46 | end repeat 47 | end tell 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Import new PDFs from Zotero into DEVONthink 2 | 3 | This AppleScript adds PDFs from Zotero to DEVONthink (only when they are not in the database yet). 4 | 5 | It imports into the current group and compares to a specific database. 6 | 7 | ## Zotero PDFs 8 | Zotero stores PDF in subfolders with random names. The subfolders are located in the user defined Zotero root -> storage. This setting cannot be changed as far as I know. 9 | 10 | Note that the stored PDFs are mixed with other stored data from Zotero. 11 | 12 | ``` 13 | …/zotero_base_path/storage/A4KJSLAJ/file1.pdf 14 | …/zotero_base_path/storage/AKJ7HHAH/file2.pdf 15 | …/zotero_base_path/storage/34jh5lhj/file3.pdf 16 | …/zotero_base_path/storage/KSJFH6KS/something.html (!) 17 | ``` 18 | 19 | ## Adding new PDFs 20 | 21 | This Apple script does the following: 22 | 23 | 1. iterate over all subfolders 24 | 2. add only PDF files to DEVONthink 25 | 3. check if there is a similar file in DEVONthink already 26 | 4. if yes delete the added file 27 | 28 | 29 | ## Install 30 | 31 | ### Adapt the script to your machine 32 | - Add the path to your Zotero `storage` folder in POSIX form ("/path/to/folder") 33 | - Add the name of the database where your papers are stored 34 | - Export as script and place in target location (e.g. scripts folder of an application) 35 | 36 | ### Install 37 | - Copy the AppleScript to your scripts folder (Scripts -> open script folder) 38 | - You can choose either the Menu or the Toolbar 39 | 40 | ## Usage 41 | Run the script from menubar or toolbar. 42 | 43 | **NOTE** 44 | - The script imports files into the *current group* 45 | - It compares only to files in the *defined database* 46 | - If you store papers in database A but compare to a database B you will import duplicates 47 | - I use a specific 'import' group in my paper library 48 | 49 | ## Todo 50 | - add bibliographic metadata 51 | 52 | ## Issues 53 | - The script always adds all PDFs. Comparison happens after adding a PDF and if it exists already the file is deleted from DEVONthink again. Thus, run time grows with number of papers and might be to slow for very large databases. For hundreds of papers it finishes within seconds though. 54 | --------------------------------------------------------------------------------