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

notepad find in files

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.

find in files

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:

  1. Find What: this is the search string that you want Notepad++ to find in the files.
  2. 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.

search text in files

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++

Summary
Article Name
Use Notepad++ to find text in all files of a folder
Description
Find out how to use the text editor Notepad++ on machines running Windows to find text in all files of a folder that you select.
Author
Publisher
Ghacks Technology News
Logo
Please share this article

Facebooktwittergoogle_plusredditlinkedinmail



Responses to Use Notepad++ to find text in all files of a folder

  1. Relational Datapost September 16, 2016 at 8:23 pm #

    3rd rank in the best editors list, after Vim and Emacs.
    Just forget hogs as Sublime or Atom.

  2. Dave September 16, 2016 at 9:50 pm #

    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.

    • Mark Reed September 17, 2016 at 12:40 am #

      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.

    • A different Martin September 17, 2016 at 4:31 pm #

      An update to Agent Ransack was released (or at least brought to my attention by SUMo) yesterday!

  3. Nebulus September 17, 2016 at 2:15 am #

    Thanks for the tip, Martin!

  4. Jozsef September 17, 2016 at 6:40 am #

    Would SciTE be the best equivalent for Linux or is there something else? I'm trying to leave the Windows vale of tears. ;)

  5. beerpatzer September 17, 2016 at 6:43 am #

    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?

  6. George September 17, 2016 at 11:35 am #

    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).

  7. Pants September 17, 2016 at 5:37 pm #

    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

  8. Jojo September 17, 2016 at 7:45 pm #

    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

    • A different Martin September 17, 2016 at 8:11 pm #

      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...")

  9. chesscanoe September 17, 2016 at 11:32 pm #

    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.

  10. C September 19, 2016 at 8:28 pm #

    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.

  11. Elvinson February 16, 2017 at 7:03 am #

    Thank You. it is working 100%

  12. Jes April 7, 2017 at 1:04 pm #

    Hi,
    I have one doubt.
    after searching a particular word ,how to go to parent page ? is there any short key for that ?

  13. JOSEPH DUNN April 18, 2017 at 10:29 am #

    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...

  14. Jojo April 18, 2017 at 2:00 pm #

    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!!

Leave a Reply