I’m sure this feature has been requested before, but a search of the forum didn’t turn up any posts. I think that this capability is essential in an otherwise superb “Professional” application.
-Steve
I’m sure this feature has been requested before, but a search of the forum didn’t turn up any posts. I think that this capability is essential in an otherwise superb “Professional” application.
-Steve
OK
It might be dangerous,but in fact I’ve never had trouble with other apps, such as BBEdit, in which multiple-file search and replace is well-designed. Why should it be any different in DTPO? One creates a set of the files to be searched and and sets options about whether to confirm each change. A robust “undo” capability certainly helps.
I came across this issue today when I wanted to change all the instances of a single term to a variant–neither was a misspelling. I knew exactly which documents contained the word to be changed, but having to search and replace document by document was truly tedious. I even thought of exporting the documents to text files so that I could use BBEdit.
Of course, a regular expressions facility would be a natural accompaniment to good search and replace functions. The new search commands taken from Devon Agent are a good start, but, in my opinion, the search and replace capabilities in DTPO could be greatly improved.
There is an easier way at least for plain text files - but not for the faint of the heart
you can point BBEdit to the folder in the database-package and perform your grep magic on all files in there:
MyDatabase.dtBase2/Files.noindex/txt/
DTP will pick up the changes without problems. Just make sure not to have any unsaved open windows in DTP.
I wish I could do that with rtf files as well and I would support the feature request for multiple document search and replace (grep support is always nice to have but for a starter a standard search and replace would be enough).
Johannes
I too would love to see this feature added
I’d like to see this feature too
Came across Brett Trepstra’s discussion of “tops” - a command line utility that can be used to replace text in multiple files at once. Should be fairly easy to implement a DEVONthink script that calls “tops” for each file in a selection.
(“tops” might be part of the Developer Tools - open a Terminal session and do “man tops” - if there’s no manual displayed, you don’t have “tops” on your machine.)
Update: I’ve posted an experimental find-and-replace script using “tops” here.
[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!Update document titles
Rename
> Replace Text…
This allowed me to change ever occurrence of “Adrian” to “Adrim” in the file list.
Update file contents
Show in Finder
Open With
> Other…
Once VS Code had saved all the file changes, they appeared instantly in DEVONThink! #problemsolved
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!