如何在Windows环境Visual Studio或任何其他IDE中查找不包含特定字符串的所有文件?

kam*_*ami 7 search find visual-studio-2010 visual-studio

如何在Visual Studio中搜索具有不包含特定字符串的特定扩展名的所有文件?在Visual Studio中查找文件功能(VS 2008或VS 2010或VS 2012)具有正则表达式选项,但我没有找到查找不包含字符串的文件的方法.我需要在项目文件夹中找到数千个文件,其中aspx.cs文件不包含字符串'security'.我找到了一些针对Windows平台的解决方案,并且想知道如何在Windows机器上执行此操作,理想情况下无需支付应用程序费用?我还发现stackoverflow上的另一个老帖子有错误的答案,并且还使用了windows grep app并且它不起作用: Visual studio查找不包含X的文件

该解决方案也适用于这篇文章:如何使用Notepad ++查找不包含字符串的目录中的文件:https: //superuser.com/questions/110350/how-to-use-notepad-to-find-files- in-a-directory-that-do-not-string-string:

@Peter McEvoy:好抓!@jerone请不要接受这个答案,因为它错了...... - jeroenh.这个解决方案不起作用.它会返回误报

kam*_*ami 13

我终于找到了解决方案来查找具有特定扩展名但不包含特定字符串的所有文件,我正在寻找一个解决方案很长一段时间,它工作得很好并且是免费的.希望这有助于其他尝试做同样事情的人.

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
Run Code Online (Sandbox Code Playgroud)