find and replace "return" and other white spaces


Would anyone have a script for removing “returns” (and other white spaces) in a RTF file?


You might have a look at WordService and its “Remove Line Endings” and “Remove Multiple Spaces” commands.

I’ve written an AppleScript that allows you to replace text within an RTf file without losing your existing formatting. It might be rough around the edges, but seems to work so far.

The script exports the record as an RTF file (as a temporary file), modifies it in the RTF source code, re-imports it to DEVONthink, then transfers the changed rich text over to the original record.

You can download it at Let me know if you have any trouble - my email is on my website -

(I originally posted version 0.8, but that created a /tmp group in your database and left it there. Version 0.9 creates the group for the import, then removes /tmp if you didn’t have it already).

NOTE: Obviously, you can do this with the Find/Replace dialog. However, this script can be modified (if you know AppleScript) to edit the file automatically in some way without having to script the GUI find/replace dialog. It could also be re-worked to run a search through the database, then loop over every found record, changing a given string to another without losing rich text formatting in every edited record. That’s my long-term plan for the script. I have plans to use it that way for my law school notes to standardize some of my names of concepts, statutes, etc.


Thanks for these great scripts. I have added them today to our scripts page in the DEVONacademy!