12

Does anyone know a quick and easy way to use Notepad++'s "find in files" (or other feature) to find files that do not contain a string?

For example:

List all files in c:\inetpub\mywebsite that do not contain "footer.asp"

2
  • 1
    How about writing a quick console app to do it? – Russ Cam Feb 17 '10 at 22:59
  • Have you tried grep? – fre0n Feb 18 '10 at 0:00
8

Make sure 'Regular expression' is selected in Search Mode.

Use the following regex to get all the files which don't contain 'Text goes here':

(?s)\A((?!Text goes here).)+\z
3
  • 2
    This one answers the question. It works with Notepad ++. – gnaanaa Jun 8 '18 at 4:35
  • It indeed works. Can somebody explain what it does? – fschmitt Sep 8 '20 at 13:25
  • @fschmitt: ((?!Text goes here).)+ or better (?:(?!Text goes here).)+ is called Tempered Greedy Pattern – Toto Feb 15 at 10:09
5

You could always use the good old DOS / Command prompt and do something like this:

find /c /i "footer.asp" c:\inetpub\mywebsite\*.* | find ": 0" /v

This will give you a list of the number of times that the search term occurs in the files in the directory, the second find operation that the first is piped through makes it even more sexy by filtering out the results from the first that you aren't interested in.

You might want to change the * . * to *.asp though if you are only hunting through ASP files and you are only interested in looking through ASP files.

FIND doesn't work with recursing sub directories unfortunately but you could experiment with the slightly more complicated FINDSTR command if this doesn't do the trick.

1
  • 1
    Remove "/v" from the command to get the list of files that do not contain the given string. – Prabu Arumugam Mar 10 '15 at 19:27
0

While it is a great tool, I don't think you can do this in Notepad++.

This Python script will print out the filenames of any non-matches:

import glob
import os

def main():
    DIR = '/path/to/my/dir'

    path = os.path.join(DIR, "*")
    files = glob.glob(path)

    for f in files:
        fh = open(f,'r')
        fc = fh.read()
        if "footer.asp" not in fc:
            print "no match found in", f
        fh.close()

if __name__ == '__main__':
    main()
0

Install cygwin, use grep:

Load the cygwin bash shell:

grep -Rv "footer\.asp" /cygdrive/c/inetpub/mywebsite

Where R is recursive and v inverts the match

1
  • 2
    How can I get the file path only in result using your cygwin code? – Nam G VU Apr 27 '11 at 12:45
-1

The entire capability of Notepad++ is encompassed within the set of community plugins that Notepad++ provides you access to. If you have a recent version of Notepad++, pull down the menu called "Plugins" and choose "Plugin Manager". Then, in that list of plugins you can browse through them all and try to find something close to what you need.

I think the most important plugin to have is TextFX followed by the XML plugin.

Also, in the Find dialogue of Notepad++ is a regular expression option. It would be an advanced topic, but its possible your answer lies there.

-1

Just open up all files in tabs, then from the find menu (with a search criteria) click "Find In All Opened Documents". I regularly find this feature useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy