AppleScript to flag PDFs for export, emailing, etc.

There seem to be multiple times when it would be nice to be able to access the full-text PDFs for a set of EndNote entries, e.g., to mail someone the PDFs related to a project.

I’ve written a rudimentary AppleScript that might help those on the Mac side do just that.  You select one or more records (e.g., everything in a group or the results of search ) and run the script.  It will set the label of the corresponding PDFs to label index 3 (which is yellow by default).  One can then search in the Finder for all files so labeled and do what one wants with them (mail, open, etc.).  This strategy seemed more flexible and less potentially destructive than having the script copy the PDFs or some such.

A weakness of the script is that it will gag if you store your PDFs within the EN library, since the file-attachment will begin “internal-pdf://” rather than a real file path.  One could fix that, but since I store my PDFs externally, I haven’t bothered.

I hope folks find this useful as a starting point for their own applications.  Please note that it is offered without warranty or support. There is no error checking.   Backups are always a good idea!


–Select one or more records in EndNote.

–This script will set the label of the 

–corresponding PDF to 3 (Yellow by default).

–One can easily find so labeled file and 

–then move, tag, copy, whatever them.

–If one stores PDFs internally, you would have to manipulate 

–“internal-PDF://” into the start of the file path.

tell application “EndNote X6”

activate

set myFile to first document

set myRecs to retrieve"selected" records in myFile

repeat with thisRec in myRecs

set thisFile to field"File Attachments" of record thisRec

tell application “Finder”

set thisFile2 to thisFile as POSIX file as alias

set label index of file thisFile2 to 3

end tell

end repeat

end tell