Skip to content

Instantly share code, notes, and snippets.

@archgrove
Created October 3, 2013 18:24
Show Gist options
  • Save archgrove/6814567 to your computer and use it in GitHub Desktop.
Save archgrove/6814567 to your computer and use it in GitHub Desktop.
Export all canvases of an Omnigraffle Professional document using osascript from the command line
on replace_string(input, search, replacement)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to search
set textItems to every text item of input
set AppleScript's text item delimiters to replacement
set res to textItems as string
set AppleScript's text item delimiters to oldDelim
return res
end replace_string
on run argv
set sourcePath to (get (item 1 of argv) as string)
set targetPath to (get (item 1 of argv) as string)
set sourceFile to POSIX path of sourcePath
set targetDir to POSIX path of targetPath
tell application "OmniGraffle Professional 5"
open sourceFile
set area type of current export settings to all graphics
repeat with cvs in canvases of front document
# Deduce a filename based on the canvas name
set currentName to name of cvs as text
set cleanName to replace_string(currentName, " ", "_") of me
set canvas of front window to cvs
# Save as both EPS and PDF
set outputFile to targetDir & cleanName & ".eps"
save front document in outputFile
set outputFile to targetDir & cleanName & ".pdf"
save front document in outputFile
end repeat
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment