PDF to PDF Bundle

Summary: Converts the selected PDF files to Skim PDF Bundles.
Requires: EagleFiler, Skim
Install Location: ~/Library/Scripts/Applications/EagleFiler/
Last Modified: 2017-03-03


This script converts the selected PDF files into .pdfd bundles that can be annotated using Skim.

Note: If you plan to use the Rename for Dropbox/Windows script, do that before running this script. This will ensure that the files inside the PDFD package are also renamed for Dropbox/Windows.

Installation Instructions · Download in Compiled Format · Download in Text Format


on run
tell application "EagleFiler"
set _selection to selected records of browser window 1
repeat with _record in _selection
if _record's universal type identifier is "com.adobe.pdf" then
my convertRecordToPDFD(_record)
end if
end repeat
end tell
end run

on convertRecordToPDFD(_record)
tell application "EagleFiler"
set _newName to my pdfdNameForRecord(_record)
set _newFile to my convertFileToPDFD(_record's file, _newName)
set _newRecords to import files {_newFile} with deleting afterwards
set _newRecord to item 1 of _newRecords
my copyMetadata(_record, _newRecord)
set _trash to trash of _record's library document
set _record's container to _trash
end tell
end convertRecordToPDFD

on convertFileToPDFD(_source, _destName)
tell application "Skim"
open _source
set _tempFolder to do shell script "mktemp -d -t 'EFPDFToPDFD'"
set _dest to _tempFolder & "/" & _destName
save document 1 as "PDF Bundle" in _dest
close document 1
return _dest
end tell
end convertFileToPDFD

on pdfdNameForRecord(_record)
tell application "EagleFiler"
set _name to _record's filename
if _name ends with ".pdf" then
set _end to (length of ".pdf") + 1
set _base to characters 1 thru -_end of _name
set _base to _name
end if
return _base & ".pdfd"
end tell
end pdfdNameForRecord

on copyMetadata(_source, _dest)
tell application "EagleFiler"
set source URL of _dest to _source's source URL
set container of _dest to _source's container
set note text of _dest to _source's note text
set _tags to _source's assigned tags
set assigned tags of _dest to _tags
set title of _dest to _source's title
set from name of _dest to _source's from name
set label index of _dest to _source's label index
set creation date of _dest to _source's creation date
set modification date of _dest to _source's modification date
set added date of _dest to _source's added date
end tell
end copyMetadata