Include file name in grep/extract results?

42 views
Skip to first unread message

severdia

unread,
May 7, 2023, 4:20:24 PM5/7/23
to BBEdit Talk
I have a lot of XML files and I'd like to grep a string and use Extract to copy that string from each file to a single CSV file. Is there a pattern for including the filename the strong was extracted from in the results? My goal is a single text file (comma separated) that contains the string found from each XML file.

I thought I saw a way to do this in BBedit, but maybe not. Is there a replace pattern for file name?

Christopher Stone

unread,
May 10, 2023, 10:48:25 PM5/10/23
to BBEdit-Talk
On May 07, 2023, at 14:17, severdia <seve...@gmail.com> wrote:

I have a lot of XML files and I'd like to grep a string and use Extract to copy that string from each file to a single CSV file. Is there a pattern for including the filename the strong was extracted from in the results? My goal is a single text file (comma separated) that contains the string found from each XML file.


Hey Severdia,

I'm not aware of any tokens that can return the file name or path during a multi-file search...

However – to get what you need you can:
  • Do a multi-file search (Cmd-Shift-F).
  • Copy the contents of the search results window.
  • Paste that into a new document.
  • Do a little post-processing.
--
Best Regards,
Chris

Reply all
Reply to author
Forward
0 new messages