-- Downloaded From: http://c-command.com/scripts/eaglefiler/pdf-to-pdfd -- Last Modified: 2008-12-05 on run tell application "EagleFiler" set _selection to selected records of browser window 1 repeat with _record in _selection if _record's kind is "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 else 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 end tell end copyMetadata