Hello, in order to collaborate on a project with people who know nothing about DT, I want to batch convert a DT group containing sub groups to a series of folders, convert individual .RTF and .RTFD files to.docx files, export PDF as PDF, .numbers and .pages as .numbers and .pages.
To process files individually would be a huge task, which I will have to repeat for other groups.
Well, there is ‘Files/Export/Folders and Files’ (or whatever it’s called in the English UI). Certainly described in the user manual, I think.
Converting RTF and RTFD – Pages might be able to do that. And Pages is scriptable. Someone already did even write it for you, and a basic internet search turned it up as the first answer:
Which of those did I not answer? Or should I have mentioned that there’s an export command in DT’s scripting dictionary permitting the automation of the export?
The tools are all there; all you have to do is to cobble together a script using them.
This is a one-off script. And as there’s no scriptable option to convert RTF(D) to .docx, a little bit of shell is used.
Select the group and run this script.
set tempdir to (path to temporary items)
tell application id "DNtp"
if (selected records) is {} then return
try
set selGroup to (first selected record whose (record type is group))
set allRTFs to search "kind:rtf" in (current group)
if allRTFs is not {} then
repeat with theRTF in allRTFs
set {name without extension:recName, path:recPath} to theRTF
set outputPath to (tempdir & recName & ".docx" as string) as string
do shell script "textutil -convert docx " & (quoted form of recPath) & " -output " & (quoted form of (POSIX path of outputPath))
set convertedDoc to import path outputPath to (location group of theRTF)
if exists convertedDoc then
tell application "System Events" to delete file outputPath
-- move record theRTF to (trash group of (database of theRTF))
end if
end repeat
end if
export record selGroup to "~/Downloads" without DEVONtech_Storage
on error
display alert "Select a group before running this script." as critical
end try
end tell
Note there is a commented out line moving the original RTF(D) to the database’s Trash. This is to not affect your original but can be uncommented, if needed. And yes, the original group could have been duplicated first but (1) I have no clue how large or small the group and (2) there’s no harm in including the originals.
I tried running the script both with the script editor and a Keyboard Maestro AppleScript action which should work.
I did not understand if the group should be chose in the sidebar or the file/folder list, so I tried both.
Out of 30 tries, the script worked once and results were spectacular. Exactly what I was looking for.
In the script editor, no error message apart from “must select a group” (although group selected). In Keyboard Maestro, I found the following in the engine log (name of the macro is GROUP .RTFD to .DOCX $wip - $wip means work in progress) :
text-script: line 1: `set tempdir to (path to temporary items)'
2025-12-12 19:55:35 Execute a Shell Script failed with script error: text-script: line 1: syntax error near unexpected token `('
text-script: line 1: `set tempdir to (path to temporary items)'. Macro “Convert GROUP .RTFD to .DOCX $wip” cancelled (while executing Execute Shell Script).
2025-12-12 19:56:36 Execute macro “Convert GROUP .RTFD to .DOCX $wip” from trigger Macro Set Palette
2025-12-12 19:56:36 Action 100318985 failed: Execute a Shell Script failed with script error: text-script: line 1: syntax error near unexpected token `('
text-script: line 1: `set tempdir to (path to temporary items)'
2025-12-12 19:56:36 Execute a Shell Script failed with script error: text-script: line 1: syntax error near unexpected token `('
text-script: line 1: `set tempdir to (path to temporary items)'. Macro “Convert GROUP .RTFD to .DOCX $wip” cancelled (while executing Execute Shell Script).
good point. There are RTF/D → Pages automator workflows that I can put in my services menu if there is no straightforward complete (including images) solution with docx. Your post just reminded me to also check for inline PDFs.