AppleScript – Export Data from Application

applescript

I'm new to AppleScript and wanted to export my citations using AppleScript. I found the following but am not sure the structure to change the following to my path folders, can you please provide an example and is this executed in the Script editor?:

tell application "Papers" 
set outFolder to ((path to desktop from user domain) as string) & "PDF Files" 
export ((publication item of every primary file item) as list) as PDF Files to outFolder 
end tell

Thanks

Best Answer

To better understand the AppleScript, try breaking it down.

Within Script Editor.app run the following:

set outFolder to ((path to desktop from user domain) as string) & "PDF Files"

After running, the Result panel will show the value outFolder is set to. This should be a path to a folder called PDF Files on your Desktop.

Does this folder exist on your Mac? If not, this is probably the cause of the problems you are seeing.

The next line in the AppleScript tells the application Papers to export to that folder. If you have problems with Paper's AppleScript behaviour, do contact the developers; they will be best placed to help you.

Add a Try Block

You can add a try block around your AppleScripts. These will provide better error messages and hopefully catch problems.

Changing the Folder

You can add an interactive folder selection by replacing the set outFolder… line to:

set outFolder to choose folder

Alternatively, change the "PDF Files" to the name of your preferred folder.