I am having an application folder with sub-folders and thousands of files in it. I want to write a batch script which lists all the files which DO NOT contain particular text, say SAMPLE_TEXT
and redirect output to a file. Please help with the script.
Inspired by http://tobint.com/blog/powershell-selecting-files-that-dont-contain-specified-content/ this powershell worked well for me;
Get-ChildItem -include *.sql -recurse | ForEach-Object { if( !( select-string -pattern "USE " -path $_.FullName) ) { $_.FullName}} > FilesMissingUse.txt
In my case I was searching for database scripts (.sql files) which were missing "USE " string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With