Use multi-file search results as a new file filter in BBEdit 14

66 views
Skip to first unread message

Geoff Hicks

unread,
Nov 3, 2021, 11:25:02 PM11/3/21
to BBEdit Talk
I have a frequent need to run a multi-file search and replace on large folder hierarchies.
Since these searches may parse thousands of files, but only find hits in a few hundred, it seems that being able to use the list of matching files as a filter for future searches would be of great time-saving benefit, since that is typically what I have to do.

The files to be modified usually contain an internal version number or datestamp which needs to be replaced whenever a match for replacement is found, but devising grep search and replace strings which can make both changes in one hit are not always possible, given that the files may be large.

At the moment, I resort to leaving the search results window open and manually stepping through each matching file and updating the version/build string with a separate grep search. This can be quite tedious.

Any suggestions, for doing this within BBEdit directly, rather than having to resort to shell scripting and perl or sed/awk?

Geoff Hicks

unread,
Nov 4, 2021, 1:51:11 AM11/4/21
to BBEdit Talk
Ha ha! Please ignore this. I have R'd the FM and found the hint that I had missed and never used before.
Let that be a lesson to me ;-)
If it's useful, it's probably already been invented. Yay!
Screen Shot 2021-11-04 at 4.49.36 pm.png

Geoff Hicks

unread,
Nov 6, 2021, 2:08:44 PM11/6/21
to BBEdit Talk
Sorry, I've been reminded that I suddenly swapped from one thousand words mode to a single picture, which I assumed would explain the solution I found in the manual.
In the screen shot in my previous post, which I assumed would be self explanatory (though might not be for those who had overlooked this feature), is a view of the Multi-File Search dialog.
Once the initial search has been performed, if there are any results found or replacements made, they will appear in a Search Results window.
Thereafter, scrolling to the bottom of the "Search in:" box in the Multi-File Search dialog will show a new section "Results Browsers" and an entry "Search Results" which can then be checked to restrict subsequent searches to only the files which matched the "Find:" pattern in the initial search.
That means it's really easy to continue with further modifications to just that group of files, such as what I needed to do, update revision/build numbers on those files alone.

I still haven't worked out why I'd never seen that before, except perhaps that it was always at the bottom of a long list of previous "Search in:" locations that I'd not thought to scroll down and see.
I know better, now :-)
Reply all
Reply to author
Forward
0 new messages