Find files that don't contain
What expression would I need to find all files in a folder that don’t contain say
Add-Content -path *.cfg -Value ‘input_overlay_enable = “true”’
I have about 1000 files and I know some of them won’t have that line present. I just don’t know which ones.
Thanks in advance.
Your question is kind of similar to this old one: https://community.notepad-plus-plus.org/topic/16141/find-content-in-files-and-rename-delete-files-not-containing-content
However, if it is too much reading for you–I just read it, there’s A LOT there–then this might work for your situation:
Find what box:
(?s)\A(?:(?!\QAdd-Content -path *.cfg -Value 'input_overlay_enable = "true"'\E).)+\z
Thanks mate. No its not to much reading at all. Simply pointing me in the right direction would have been a sufficient answer.
Thank you for the time it took you.
Certainly, the regex, below, does work properly in the majority of cases :
However, when files scanned have a size greater than
8 Mb, about, this regex may fail and wrongly matches a file which does contain your specific expression ! I did some tests with such a file, containing the string
Your expressiononce only !
If so, here is a quicker and safer regex which is able to handle huge files. I personally tested a file of
2,000,000lines, without any trouble ! This file contained only a single line with the string
=> You’ll get your expected list of files which do not contain the string
Your expression, with this exact case ;-))
In order to get the list of the files, with their full path, displayed in the
Find resultpanel, pasted into a new tab, follow these steps :
Right-click on any zone of the
Ctrl + Cshortcut ( do not use the
Copyoption ! )
Ctrl + Nshortcut to open a new N++ tab
Ctrl + Vshortcut to paste the results, into this new tab
Finally, perform the following regex S/R, below :
^(?!\x20\x20).*\R|\Q (1 hit)\E$
Thank you so much for a helpful and constructive reply. I am learning and this really helped a lot. Thanks for a clear explanation.