Skip to content

Instantly share code, notes, and snippets.

Last active December 7, 2016 19:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Apple Script to convert old Documents to RTF using iWork '08
property PagesApp : ((path to applications folder) as text) & "iWork '08:" & ""
on open theDroppedItems
repeat with a from 1 to count of theDroppedItems
set theCurrentItem to item a of theDroppedItems
tell application "Finder"
set isFolder to folder (theCurrentItem as string) exists
end tell
-- Process a dropped folder
if isFolder = true then
-- Process a dropped file
end if
end repeat
end open
on processFolder(theFolder)
-- NOTE: The variable theFolder is a folder reference in AppleScript alias format
-- Retrieve a list of any visible items in the folder
set theFolderItems to list folder theFolder without invisibles
-- Loop through the visible folder items
repeat with a from 1 to count of theFolderItems
set theCurrentItem to ((theFolder as string) & (item a of theFolderItems)) as alias
open {theCurrentItem}
end repeat
-- Add additional folder processing code here
end processFolder
on processFile(aFile)
tell application PagesApp
open aFile
set fullpath to POSIX path of aFile as string
set endc to (length of fullpath) - (offset of "/" in (reverse of text items of fullpath as string))
set parentpath to text 1 thru endc of fullpath
tell application "System Events"
tell process "Pages"
set frontmost to true
click menu item "Export…" of menu 1 of menu bar item "File" of menu bar 1
click radio button "RTF" of radio group of sheet 1 of window 1
click button "Next..." of sheet 1 of window 1
keystroke parentpath
key code 36
click button "Export" of sheet 1 of window 1
end tell
end tell
close front document saving no
end try
end tell
end processFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment