Use Notepad++ to find text in all files of a folder
Notepad++ is quite the versatile text editor for Windows even if you ignore the program's plugin system for a moment which extends it even further.
One of the features that I make use of regularly is the program's ability to search for text in all files of a folder that I specify.
Today for instance I was informed that the cookie handling for users who leave comments here on this site changed.
All I knew was that the cookie expiration time was set to the same day and not the next year. I suspected one of the plugins installed on the site responsible for that, but did not know which.
While I could analyze the issue using trial and error, by disabling plugins one by one and verifying if that operation resolved the issue, I decided to use NotePad++ for that instead.
The idea was to search through all plugin files and return any lines of code that would either alter cookies, or search for specific variables.
Find text in all files of a folder
Start Notepad++ on your system to get started with the operation. You don't need to open a text file in the program on start, as it does not matter for the find operation that you are about to run.
Select Search > Find in Files from the menu. If you like keyboard shortcuts better, use Ctrl-Shift-F to open the search window instead.
The find in files configuration window is pretty easy to use as you can ignore most options if you don't require them.
What you need to configure are the following fields:
- Find What: this is the search string that you want Notepad++ to find in the files.
- Directory: this is the root folder that contains all the files that you want searched. Notepad++ searches all subfolders as well by default.
All other fields are optional. If you leave everything as is, Notepad++ will crawl all files of the selected root folder and all subfolders that it contains, and return all hits at the end of the search.
Optional parameters may be useful however. You can change filters, so that only certain file types, e.g. *.css or *.php, or file names, finance.* are included in the search.
You may also enable match whole word or match case options, or switch from a normal search mode to an extended search mode or one that uses regular expressions.
Last but not least, you may use the replace option to replace the text you entered with other text.
Click find all to get started. The search time depends largely on your selection, but should not take long.
Notepad++ returns all hits sorted by file and line afterwards.
All that is left is to go through the results line by line to find what you are looking for (which I did not by the way, but that is another story).
Now read: Trimming the Fat in Notepad++
FYI you can also right click on the search results and select the option to copy pathname(s) in v8.4.4 on windows anyway
Thank you for this awesome tip..!
Alas, on my first try, Notepad++ was not very effective. I searched my Docs folder for the text string “Adam Smith”, andeonly one instance was found – although I know there are at least 10 from W10 Search. Will try other progs, but thanks for the suggestion.
Search Note is an impressive way to search content inside your shared documents.
Why don’t you give it a try? Search note is available on github.
https://github.com/scorpionit01/SearchNote
Merci beaucoup depuis la France ;-)
muchas gracias desde Argentina!!!
Thanks for a nice tip!
Could you please let me know if we can enter the string values (to be searched) from a specific NPP file (say reference.txt) and then perform a search of all values present in that input file “reference.txt”.
Doesn’t work for me on a Right to Left lang…
Searched for words I know exsist in my txt files in My Documents, for example… Tried 2 words, 1 word… Nada. Single letter search seems to have worked…
Should it matter whether I’m using a Portable or an Installed N++? I guess not, right?
Bummer
p.s.
On another happier note – I see Ghack’s directed to a HTTPS now – at last, nice!!
THIS PROGRAM SUCKS BIG TIME. AFTER I HAD NOTBOOK++ CHANGE MY ALL MY STUFF IN MY FOLDERS, NOW I CAN’T ACCESS MY STUFF NOW. THIS DOES NOT WORK WELL!!!! MY RESPONSE IS THIS…
SECURITY BLAH BLAH BLAH…
Hi,
I have one doubt.
after searching a particular word ,how to go to parent page ? is there any short key for that ?
Thank You. it is working 100%
Excellent tip Martin.
One feature that some people may not realize is there.
PSPad is another free editor. It has support for a wide range of file types.
It searches in directories, and sub-directories too. Its also free.
TextPad is very good and offers a similar feature list to PSPad. Its not free though.
I love NotePad++ and have been using it for years. However for my purposes, I prefer to find specific content, in text files for example, by invoking UltraSearch. I’m not claiming it’s best; perhaps it’s just what I’m used to.
Nice article!
Wasn’t aware of that option, and to be honest haven’t used the in a very long time!
What I’ve been using for text search instead is my file search program, called ‘locate32’,i think it works ;)
But imma check it out!
Thanks
Yeah, I didn’t know about it either. I’m not a coder, so I don’t have much call for advanced functions in programs like Notepad++ and, accordingly, don’t go looking for them. I may check this one out, however.
I like pulling up XML files (which I do sometimes edit, e.g., for FreeFileSync) in Notepad++ because it does a nice job of coloring the tags and different nesting levels, resulting in fewer mistakes for an incipient Mr. Magoo like me. Also, by default it restores the previous “session” of open tabs. I install multiple versions of LibreOffice as “parallel” (~portable) installs but I have to manually edit each version’s bootstrap.ini file to point it to my LibreOffice user profile. Whenever a new version of LibreOffice comes out, it’s really handy to open its bootstrap.ini file in Notepad++ and have a tab containing a previously revised bootstrap.ini file already loaded and ready to copy from. It saves me the severe mental anguish of having to hunt down a “known-good” bootstrap.ini file each time.
Anyway, I like Notepad++ well enough, and Don Ho seems to be a pretty nice guy, even though I was disappointed to learn that he doesn’t actually lead a double life, coding in Paris during the day and entertaining tourists in Hawaii at night. (“Tiny bubbles…”)
On a side note: I had to search two logs files the other with a combined size of 6GB .. LogExpert (not just for log files): haven’t tried any others
Thanks for the info, Martin. Was wondering if it’s possible to exclude folders from the search. After a quick look it seems it isn’t possible, but a workaround would be to mark the folder you want excluded as Hidden (right-click/Properties). Notepad++ won’t look there by default (“In hidden folders” option, visible in the posted screenshot).
Out of context, but is there a program that lets you “send to” a file regardless of what format it is? If it’s a text file, it would show text, if it’s a picture, it would show you the picture, and if it’s a binary, it would show you the hex code?
Would SciTE be the best equivalent for Linux or is there something else? I’m trying to leave the Windows vale of tears. ;)
Thanks for the tip, Martin!
I think Programmers’ Notepad 2 is much better than Notepad++, not least for its stability and Python script support.
As for the task at hand, I’d use Agent Ransack. It’s old but well maintained and very good at what it does.
An update to Agent Ransack was released (or at least brought to my attention by SUMo) yesterday!
Programmer’s Notepad 2 and Notepad++ are great, however PN2 has not been updated since 2011.
For lightweight activities, like checking small logs or readme files, I prefer SciTE. Notepad++ being based on Scintilla, allows me to use the same shortcuts as with SciTE.
3rd rank in the best editors list, after Vim and Emacs.
Just forget hogs as Sublime or Atom.