Skip to content

Instantly share code, notes, and snippets.

@dpinney
Created July 6, 2021 15:43
Show Gist options
  • Save dpinney/f5de675274c9f1ad16df6794d614dea8 to your computer and use it in GitHub Desktop.
Save dpinney/f5de675274c9f1ad16df6794d614dea8 to your computer and use it in GitHub Desktop.
Convert all RTF and RTFD files to Word DOCX via AppleScript
# We do this with Pages because it's the only thing that can correctly convert rtfd.
# textutil works on rtf files with no text in them but not on rtfd.
set my_paths to {"/path/to/first/file.rtfd", "/path/to/second/file.rtfd"}
repeat with my_path in my_paths
tell application "Pages"
set my_file to (my_path as POSIX file)
set my_name to name of (info for my_file)
set doc to open my_file
export doc as Microsoft Word to alias (my_path & ".docx" as POSIX file)
close doc
tell application "Finder" to delete my_file
end tell
end repeat
@dpinney
Copy link
Author

dpinney commented Sep 22, 2022

Congrats! Nice hacking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment