I need to apply the “Format > Change to plain text command” to approximately 4000 .rtf files lumped together in a folder. My knowledge of Applescript is negligible but my understanding is that no Applescript interface exists for this command.
Is it indeed so? Curiously, when selecting more than one .rtf the menu command appears grayed-out. Is this something the devs would consider changing in a subsequent “dot” release?
As a last resort, I tried to record a macro in Automator, recording mouse movements and key strokes, but it doesn’t work. (This does not surprise me, it is a feature that rarely delivers.)
Why not do this manually, you may ask. Well, simply because each iteration takes about 35 seconds to complete here—my system is slow and the index very large.
What about converting the documents to plain text (see menu Data > Convert > to Plain Text) and deleting the original documents? That should do the job too.
Thanks for the reply. I would do that but need each .txt file to have the same UUID as the .rtf it replaces, so that my x-devonthink-item:// links do not break.
Then, in that case, Format > Change is not scriptable by telling DEVONthink to apply the command. But a script that calls on UI scripting (using System Events to press keys such as that menu command) together with the available commands in the DEVONthink scripting dictionary would be possible without much trouble.
It’s actually scriptable without using user interface scripting even though the script might appear weird initially
tell application id "DNtp"
set theSelection to the selection
repeat with theRecord in theSelection
if type of theRecord is rtf or type of theRecord is rtfd then
set plain text of theRecord to (plain text of theRecord)
end if
end repeat
end tell