Get full path of the attachment (selected item)
Get full path of the attachment (selected item)
Can you help me to get an apple script that can get me the absolute path of the attachment of a selected reference? At the moment (without AppleScript), I have a format in Bookends that includes full path and I manually copy the full path, although it works it is a tedious process (I have to choose the format first, select the formatted text, copy it and past it to terminal (for file transfer)
Re: Get full path of the attachment (selected item)
Using Bookends 13.2.1 or greater, the below AppleScript code should work:
Code: Select all
-- Returns the absolute path of the first attachment of the first publication
-- selected in the front Bookends window.
tell application "Bookends"
tell front library window
set selectedPubs to selected publication items
if selectedPubs is not {} then
set aPub to first item of selectedPubs
set filePath to my firstAttachmentPathFromPublication(aPub)
get filePath
end if
end tell
end tell
-- For the given Bookends publication, returns the absolute path of its
-- first attachment (if there's any), otherwise returns an empty string.
on firstAttachmentPathFromPublication(aPublication)
if aPublication is missing value then return ""
tell application "Bookends"
set pubFiles to attachment items of aPublication
if pubFiles is {} then return ""
set aFile to first item of pubFiles
set filePath to path of aFile
return filePath
end tell
end firstAttachmentPathFromPublication