Skip to content

Instantly share code, notes, and snippets.

@mac-cain13
Last active August 29, 2015 14:11
Show Gist options
  • Save mac-cain13/fa392f6eebe6c4f2d656 to your computer and use it in GitHub Desktop.
Save mac-cain13/fa392f6eebe6c4f2d656 to your computer and use it in GitHub Desktop.

Convert iWork to Office mapactions

Automatically convert Pages and/or Keynote files added to a certain folder into Word and/or Powerpoint files. Just throw in the iWork files and this scripts will convert them into Office files in the same folder. The iWork versions will be moved to the trash.

Setup

  1. Copy the two AppleScript files to ~/Library/Workflows/Applications/Folder Actions
  2. Create a conversion folder where you'll put the files you want to convert
  3. Right click the folder, choose configure folder actions, check the "Enable folder actions" checkbox and attach the pages-to-word.scpt and/or keynote-to-powerpoint.scpt to your folder

Now just copy files into this folder whenever you want to convert them. Please note that on older Macs it can take a bit of time to convert files, just give Pages/Keynote some time to do their job and everything will be fine!

-- Author: Mathijs Kadijk
-- License: MIT License
-- From: https://gist.github.com/mac-cain13/fa392f6eebe6c4f2d656
on adding folder items to thisFolder after receiving addedItems
set posixFolder to POSIX path of thisFolder
repeat with currentItem in the addedItems
tell application "Finder"
set extension to name extension of currentItem
end tell
if extension is "key" then
tell application "Finder"
set itemName to name of currentItem
set delims to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
--strip .key extension from the filename
if itemName contains "." then set itemName to (text items 1 thru -2 of itemName) as text
set AppleScript's text item delimiters to delims
set exportPath to posixFolder & itemName & ".pptx"
end tell
tell application "Keynote"
set theDocument to open currentItem
export theDocument to POSIX file exportPath as Microsoft PowerPoint
close theDocument
end tell
tell application "Finder"
move currentItem to trash
end tell
end if
end repeat
end adding folder items to
-- Author: Mathijs Kadijk
-- License: MIT License
-- From: https://gist.github.com/mac-cain13/fa392f6eebe6c4f2d656
on adding folder items to thisFolder after receiving addedItems
set posixFolder to POSIX path of thisFolder
repeat with currentItem in the addedItems
tell application "Finder"
set extension to name extension of currentItem
end tell
if extension is "pages" then
tell application "Finder"
set itemName to name of currentItem
set delims to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
--strip .pages extension from the filename
if itemName contains "." then set itemName to (text items 1 thru -2 of itemName) as text
set AppleScript's text item delimiters to delims
set exportPath to posixFolder & itemName & ".docx"
end tell
tell application "Pages"
set theDocument to open currentItem
export theDocument to POSIX file exportPath as Microsoft Word
close theDocument
end tell
tell application "Finder"
move currentItem to trash
end tell
end if
end repeat
end adding folder items to
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment