Last active
December 16, 2015 16:40
-
-
Save charlesbedrosian/5464768 to your computer and use it in GitHub Desktop.
This script prompts for a folder, then recursively generates PDFs of all graffles found, using the name of the graffle and saving the PDF to the graffle's same folder.
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
property kGraffleAliasList : {} | |
tell application "Finder" | |
set source_folder to choose folder with prompt "Please select directory." | |
my createList(source_folder) | |
kGraffleAliasList | |
my convertGraffles() | |
end tell | |
on createList(item_list) | |
set the the_items to list folder item_list without invisibles | |
set item_list to item_list as string | |
repeat with i from 1 to number of items in the the_items | |
set the_item to item i of the the_items | |
set the_item to (item_list & the_item) as alias | |
set this_info to info for the_item | |
set file_name to name of this_info | |
if file_name ends with ".graffle" then | |
set end of kGraffleAliasList to the_item | |
end if | |
if folder of this_info is true then | |
my createList(the_item) | |
end if | |
end repeat | |
end createList | |
on convertGraffles() | |
tell application "OmniGraffle Professional 5" | |
repeat with i from 1 to number of items in kGraffleAliasList | |
set graffle_alias to item i of kGraffleAliasList | |
tell application "Finder" | |
set parent_folder to (container of graffle_alias) as string | |
set graffle_name to name of graffle_alias | |
end tell | |
set file_basename to texts 1 through -9 of graffle_name | |
set pdf_file to parent_folder & file_basename & ".pdf" | |
open graffle_alias | |
set graffle_document to front document | |
save graffle_document in pdf_file | |
close graffle_document | |
end repeat | |
end tell | |
end convertGraffles |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment