How to find all files that DO NOT contain a specific string in Windows Visual Studio or any other IDE?

How do you search in Visual Studio for all files with a specific extension that DO NOT contain a specific string? The Find in Files feature in visual studio (VS 2008 or VS 2010 or VS 2012) has a regex option, but I have not seen a way to find files that do not contain a string. I need to find thousands of files in the project folder in which the aspx.cs files do not contain the string "security". I found some solutions for the Windows platform and wondered how to do this on a Windows machine and, ideally, without paying for the application? I also found other old messages in stackoverflow with incorrect answers, and also used the grep windows application and it did not work: Visual studio Find files that DO NOT contain X

The solution also applies to this post: How to use Notepad ++ to search for files in a directory that does not contain a string: https://superuser.com/questions/110350/how-to-use-notepad-to-find-files-in -a-directory-that-do-not-contain-string :

@ Peter McEvoy: good booty! @jerone pls disagree with this answer as it is wrong ... - jeroenh. This solution does not work. It will return false positives.

+7
source share
2 answers

Finally, I found a solution to find all files with a specific extension that DO NOT contain a specific string, I searched for a solution for a long time, and it works great and free. Hope this helps others who are trying to do the same.

GOTO EndComment 1st Change source, destination, extension and string to your needs. 2nd Remove ECHO from line 19 (If you want to make a copy of those specific files that contain the string to destination folder) 3rd Save this piece of code on a file file with extension .cmd and run it to get results (just double click on file). :EndComment @echo off setlocal set source=c:\Users\youruseraccount\Documents\Visual Studio 2012\PathofProject\ set destination=c:\foundFilesWithoutString\ set extension=*.aspx.cs set string=Security for /f "tokens=*" %%G in ('dir /s "%source%\%extension%" /a:-d /b') do ( find /c /i "%string%" "%%G" > NUL || ( ECHO copy "%%G" "%destination%" ) ) pause 
+13
source

There is an extension for Visual Studio code to search for files that do not contain a specific string. Reverse Lookup

0
source

All Articles