[Cross-posting this here as well.]
From what I can tell, no changes have been made within the app to support multi-file search-and-replace, so I figured I’d share the solution I ended up using in case it helps someone else down the line.
While @korm’s script is much appreciated, the warnings gave me pause, so I sought something a little more robust and familiar. Enter VS Code.
I haven’t spent enough time with this to be 100% sure that I didn’t bork something. So far so good, though.
Use Case
I have a few thousand markdown files exported from Ulysses representing about 5 years of world-building notes for a future fiction book series. About two years in, I changed the name of a major character, but didn’t bother to go back and fix it because, well, Ulysses also doesn’t have a global search-and-replace.
I’d already imported all the files into DT by way of discovering whether it’s got what I need to help me rediscover my own thoughts (answer: probably!). I’d also completed a major tagging exercise designed to help me track the source of each note as I begin to slice and dice and rearrange them. Only mentioning this because, if I’d known that global search-and-replace wasn’t going to be available in-app, I’d probably have reversed the order, fixing updating the character’s name in the original markdown files before importing into DT.
The Solution
-
Prep
-
File
>Export
>Database Archive…
#safetyfirst! - Smart Group to collect all files containing the old character name
-
-
Update document titles
- Select all files in the Smart Group
- Scripts menu >
Rename
>Replace Text…
This allowed me to change ever occurrence of “Adrian” to “Adrim” in the file list.
-
Update file contents
- Right-click on the database and select
Show in Finder
- Right-click on the revealed .dtBase2 file >
Open With
>Other…
- Select Visual Studio Code
- Perform a global replacement in VS Code, being careful to use whole-word search and carefully inspecting the search results before performing the bulk replacement. Caveat lector: this is where it’s possible to do some real damage if you don’t know what you’re doing!
Once VS Code had saved all the file changes, they appeared instantly in DEVONThink! #problemsolved
- Right-click on the database and select
Needless to say, this should work with any other text editor, be it a command-line tool, Atom/Sublime, BBEdit…whatever. It’s rather wonderful that DT’s “database” is just a file bundle rather than in some inscrutable binary, thus enabling this kind of back-door power fix.
Thanks again, DT Team!