Created
September 3, 2019 02:38
-
-
Save cawka/d7ca3336c36b5277b4b0090b1dc3c21f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/osascript | |
on run argv | |
if not (count argv) = 2 | |
return "Usage:\n graffle2pdf <input file> <output file>" | |
end if | |
set pwd to do shell script "pwd" | |
set _input to item 1 of argv as text | |
set _output to item 2 of argv as text | |
if not _input starts with "/" | |
set _input to pwd & "/" & _input | |
end if | |
if not _output starts with "/" | |
set _output to pwd & "/" & _output | |
end if | |
try | |
set _input to (get POSIX file _input as alias) | |
on error errStr number errorNumber | |
return "ERROR: File [" & _input & "] does not exists or cannot be opened" | |
end try | |
set _output to (get POSIX file _output as string) | |
tell application id "com.omnigroup.OmniGraffle6" | |
set docs to (every document whose path is _input) | |
if (count docs) = 1 then | |
set doc to item 1 in docs | |
save doc in file _output | |
else | |
open _input | |
save the first document in file _output | |
close the first document | |
end if | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment