Skip to content

Instantly share code, notes, and snippets.

@dpinney
dpinney / convert_all_rtf_and_rtfd_to_docx.scpt
Created July 6, 2021 15:43
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)