I’m trying to create a script that will export the current database files (a mimic of File>Export>Files and Folders) to a specific folder.
tell application "DEVONthink Pro"
try
if not (exists current database) then error "No database is open."
set this_database to current database
set database_name to name of current database
set this_date to do shell script "date +%Y-%m-%d"
set export_name to this_date & " | " & database_name as string
end try
end tell
tell application "Finder"
make new folder at alias "Macintosh HD:Users:user:Desktop:" with properties {name:export_name}
end tell
tell application "DEVONthink Pro"
export data of this_database to "Macintosh HD:Users:user:Desktop:"
end tell
end tell
A few things I’m having trouble with:
Getting the right syntax for DevonThink Pro to export the files and folders of the current group…
I’d like to export the content to a new folder I created, but how would I reference that folder?
Sorry, but my AppleScript knowledge is bare, so I appreciate any help you can send my way.
Seems to me it would be simpler to use the DEVONthink actions in Automator and build a workflow to do this. Those actions include selecting databases, groups, exporting, etc.
I can create a folder with Today’s date in My Documents>Receipts Exports
I can export my database, but how to I select the folder that has not yet been created during the workflow?
tell application "DEVONthink Pro"
try
if not (exists current database) then error "No database is open."
set this_database to current database
set this_root to root of current database
set database_name to name of current database
set this_date to do shell script "date +%Y-%m-%d"
set export_name to this_date & " | " & database_name as string
end try
end tell
try
tell application "Finder"
set this_folder_properties to the properties of (make new folder at alias "Macintosh HD:Users:ndouglas:Desktop:" with properties {name:export_name})
set this_folder to folder (name of this_folder_properties) of (container of this_folder_properties) as string
set this_path to POSIX path of this_folder
end tell
tell application "DEVONthink Pro"
export record this_root to this_path
end tell
end try
Does that help? Let me know if you have any problems, and thanks for your post
Note that the script posted above is hardcoded to the specific structure of Nathan’s machine. You’ll need to adjust the “set this_folder_properties …” statement to the desired destination on your machine, or tell Finder to open a file dialog and select a destination.
I’m trying to rig up a version of this script. How do I adjust the “set this_folder_properties …” statement so that it saves to a folder on an external HD? Also, where would I save this script? To DTP’s Scripts folder? Somewhere else? Excuse my ignorance w/ AppleScripts…