How to find all files that do NOT contain specific string in windows environment Visual Studio or any other IDE?
find, search, visual-studio, visual-studio-2010
Solution
I finally found solution to find all files with certain extension that do NOT contain a specific string, I was looking for a solution to this for a long time, and it works great and is 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
Problem
How do you search in Visual Studio all files with certain extension that do NOT contain a specific string? Find in Files feature in visual studio ( VS 2008 or VS 2010 or VS 2012) has regex option but I did not see a way to find files that do not contain a string. I need to find in a project folder with thousands of files which aspx.cs files do not contain the string 'security'. I found some solutions no for windows platform, and was wondering how to do this on a windows machine and ideally without paying for an application? I also found another old posts on stackoverflow with wrong answers, and also used windows grep app and it did not work: Visual studio Find files that does NOT contain X The solution also applies to this post: How to use Notepad++ to find files in a directory that do not contain string : https://superuser.com/questions/110350/how-to-use-notepad-to-find-files-in-a-directory-that-do-not-contain-string : @Peter McEvoy: good catch! @jerone pls unaccept this answer as it's wrong... – jeroenh. this solution does not work. It will return false positives