187

I have to change some connection strings in an incredibly old legacy application, and the programmers who made it thought it would be a great idea to plaster the entire app with connection strings all over the place.

Visual Studio's "current project" search is incredible slow, and I don't trust Windows Search.

So, what's the best free, non-indexed text search tool out there? All it should do is return a list with files that contain the wanted string inside a folder and its subfolders.

I'm running Windows 2003 Server.

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
kitsune
  • 11,516
  • 13
  • 57
  • 78
  • `010 Editor` searchs huuuge files in 0 second. – Morteza Sep 01 '15 at 14:39
  • Depeche View beats everything else on this page, hands down. There are a few shortcuts you'll want to take a couple mins to read the help file and learn though. http://stahlworks.com/dev/depeche-view.html – BVernon May 26 '16 at 17:48
  • I use this a lot too, however it forces you to click on each result file to see the content matches on the right pane. Also the file content on the right pane is not zoomable (font size is too small). – Meryan Mar 22 '17 at 07:27
  • This is a good question for software engineering, but offtopic on SO. Which SE network site is it on-topic? See e.g. [SE.SE questions on 'search codebase'](https://softwareengineering.stackexchange.com/search?q=search+codebase+is%3Aq+votes%3A2) We should migrate this question so it can be reopened! – smci Dec 05 '18 at 01:59
  • voidtools search everything is the best windows search tool, it can also search inside files with the content: keyword – peter Feb 21 '19 at 21:11
  • 1
    Have a look at File Content Finder on the app store (disclaimer - I'm the developer). It can search in text/source files, but also in pdf, doc(x), xls(x), and even scanned jpg/png files - https://www.microsoft.com/en-au/p/file-content-finder/9mzc4sk6j6bp – Geo Systems Apr 15 '19 at 12:29
  • If you happen to have IntelliJ IDEA (or any other Jetbrains IDE) open, you can use "Find in Path" (Ctrl + Shift + F). Select "Directory" and enter your desired path. – Impulse The Fox Apr 30 '19 at 10:33

6 Answers6

386

I'm a fan of the Find-In-Files dialog in Notepad++. Bonus: It's free.

enter image description here

SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
BQ.
  • 9,393
  • 3
  • 25
  • 35
  • Which unfortunately can't -- or doesn't-- search all Microsoft Word files. Something about the difference between ".doc" and ".docm" I suspect – Carl Witthoft Jan 17 '14 at 17:44
  • 12
    @CarlWitthoft `.docm`, like `.docx`, `.xlsm`, and `.xlsx` are actually zipped XML documents. – Ian Boyd Feb 03 '15 at 21:58
  • 1
    it works well for small folders with a normal number of files, hangs for large sized with many files folders, at least when I use my laptop. A bit faster when using powerful PC. Moreover, while it's searching, cannot open any other files. – Mohammed Joraid Feb 12 '15 at 14:09
  • Found my text. However, did not allow me to select in the results which values to replace and which to keep. All or nothing? – ofer.sheffer Mar 13 '15 at 20:22
  • find in files notepad is the slowest I've ever used. Much slower than other tools that I've tried in ~6GB project, and for projects ~20GB it fails to find for a lot of lines while MSVC's still work well – phuclv Apr 03 '15 at 09:50
  • 5
    Had no idea this was even an option in notepad++. Great solution to find missing files! It does, however, seem to have issues with large file sizes. Occasionally it gives the "file too large to open" error. – Hooplator15 Nov 18 '16 at 12:54
  • NPP support for Arabic text is poor, it swaps location of the actual text (not only in Search results but in the editor as well). NPP 5 filed requests around Arabic support don't seem to be addressed and blame it to "limitations" of the Scintilla component used in NPP – Meryan Mar 22 '17 at 08:03
  • You can try File Content Replacer. It can search lots of files like word document, excel fiile, pdf and text files. It also has and option to replace text in the files. It is very affordable. Try their free trial on : https://kingsoftware.co.za/OrderFileContentReplacer.aspx – chosenOne Thabs Mar 26 '17 at 16:53
  • Cool feature, didn't know there is something like this in Notepad++. However, it does not find results in Excel files. – rluks Apr 05 '18 at 11:11
  • In case someone wonders, Sublime Text has this cool feature as well. – ndrplz Jul 10 '19 at 06:44
  • it crashes for me :( – thomachan Sep 03 '19 at 05:12
  • It completely hangs notepad++. Such a poor design. – Vaibhav Jain Oct 05 '20 at 10:13
194

There is also a Windows built-in program called findstr.exe with which you can search within files.

>findstr /s "provider=sqloledb" *.cs
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
JohnnyFromBF
  • 9,873
  • 10
  • 45
  • 59
  • 3
    Simple and efficient! – Markus Fantone Sep 02 '15 at 16:46
  • This is much faster than Windows Explorer and actually found the text I was searching for, whereas using Windows Explorer didn't yield search results for me. Thanks. – mbomb007 Nov 12 '15 at 14:44
  • 1
    For me, the best answer on this topic because you do not need to install anything. In my case I had to complement adding some arguments because is too much information to appear on the screen. The argument /M lists just the file name that has the information that I was looking for. To access the manual of findstr command, type "findstr /?" in the console. – Alexandre Ribeiro Oct 13 '17 at 11:41
  • This is a great util, but it seems it can't read Cyrillic characters in file names. For example: `FINDSTR: Cannot open ???????????.txt` – Artem Russakovskii Feb 16 '19 at 19:36
  • 1
    findstr doesn't support UTF16 text. – David Bremner Mar 14 '19 at 18:33
  • findstr is great, I recommend options s (all files and subdirs), p (skip non-readable), i (ignore case), and n (print line number) for most cases (`findstr /spin "[string]" *.*`) – stjns Nov 21 '19 at 21:52
  • This is the best solution imho! – gluecks Feb 09 '22 at 09:37
  • For file with long lines you unfortunately get FINDSTR: Line X is too long. – Pux Sep 26 '22 at 08:41
68

Original Answer

Windows Grep does this really well.

Edit: Windows Grep is no longer being maintained or made available by the developer. An alternate download link is here: Windows Grep - alternate

Current Answer

Visual Studio Code has excellent search and replace capabilities across files. It is extremely fast, supports regex and live preview before replacement.

enter image description here

D'Arcy Rittich
  • 167,292
  • 40
  • 290
  • 283
37

I like AstroGrep. The results are shown in a list. A click on a row shows you the whole line as a preview highlighting the hit. It seems to be quite fast, lean and it is free. Tested on Windows 7, 8, 10 and Windows Server 2008 R2. Allows regular expressions.

Latest AstroGrep Screenshot

AstroGrep is a Microsoft Windows GUI File Searching (grep) utility. Its features include regular expressions, versatile printing options, stores most recent used paths and has a "context" feature which is very nice for looking at source code

Reference: AstroGrep

Anytoe
  • 1,605
  • 1
  • 20
  • 26
  • 7
    Off all the other ones listed here, this is the only that lets specify exclusion patterns for folders. Mighty helpful when trying to skip folders like `node_modules` or `bower_components`. – Mrchief Nov 02 '16 at 15:05
  • 1
    Very good software, fast, configurable, and show files along with related context – HanniBaL90 Nov 17 '17 at 13:22
  • 1
    And 'fast' deserves a second mention... `self == happy` – cssyphus Dec 05 '18 at 22:36
9

Visual Studio's search in folders is by far the fastest I've found.

I believe it intelligently searches only text (non-binary) files, and subsequent searches in the same folder are extremely fast, unlike with the other tools (likely the text files fit in the windows disk cache).

VS2010 on a regular hard drive, no SSD, takes 1 minute to search a 20GB folder with 26k files, source code and binaries mixed up. 15k files are searched - the rest are likely skipped due to being binary files. Subsequent searches in the same folder are on the order of seconds (until stuff gets evicted form the cache).

The next closest I've found for the same folder was grepWin. Around 3 minutes. I excluded files larger than 2000KB (default). The "Include binary files" setting seems to do nothing in terms of speeding up the search, it looks like binary files are still touched (bug?), but they don't show up in the search results. Subsequent searches all take the same 3 minutes - can't take advantage of hard drive cache. If I restrict to files smaller than 200k, the initial search is 2.5min and subsequent searches are on the order of seconds, about as fast as VS - in the cache.

Agent Ransack and FileSeek are both very slow on that folder, around 20min, due to searching through everything, including giant multi-gigabyte binary files. They search at about 10-20MB per second according to Resource Monitor.

UPDATE: Agent Ransack can be set to search files of certain sizes, and using the <200KB cutoff it's 1:15min for a fresh search and 5s for subsequent searches. Faster than grepWin and as fast as VS overall. It's actually pretty nice if you want to keep several searches in tabs and you don't want to pollute the VS recently searched folders list, and you want to keep the ability to search binaries, which VS doesn't seem to wanna do. Agent Ransack also creates an explorer context menu entry, so it's easy to launch from a folder. Same as grepWin but nicer UI and faster.

My new search setup is Agent Ransack for contents and Everything for file names (awesome tool, instant results!).

Steve
  • 571
  • 5
  • 10
3

If you don't want to install Non-Microsoft tools, please download STRINGS.EXE from Microsoft Sysinternals and make a procedure like this one:

@echo off
if '%1' == '' goto NOPARAM
if '%2' == '' goto NOPARAM
if not exist %1 goto NOFOLDER

echo ------------------------------------------
echo - %1 : folder
echo - %2 : string to be searched in the folder
echo - PLEASE WAIT FOR THE RESULTS ...
strings -s %1\* | findstr /i %2 > grep.txt
notepad.exe grep.txt

goto END

:NOPARAM rem - input command not correct
echo ====================================
echo Usage of GREP.CMD:
echo   Grep "SearchFolder" SearchString
echo Please specify all parameters
echo ====================================
goto END

:NOFOLDER
echo Folder %1 does not exist
goto END

:END rem - exit
CJBS
  • 15,147
  • 6
  • 86
  • 135
FIBA
  • 101
  • 1
  • 2