118

I'm looking for a way to get n++'s find in files dialog to exclude certain files...

the only reference I've found so far is this http://sourceforge.net/project/shownotes.php?release_id=536795&group_id=189927 , but, unfortunately, it doesn't work.

I'm using *[^*.dll] to, I think, search for everything BUT dll files.

How can I resolve this ?

Thanks

2
  • 2
    The feature was recently implemented and hopefully the np++ guys accept it... github.com/notepad-plus-plus/notepad-plus-plus/pull/4429 Add your comments and thumbs up to the pull request and maybe we can trigger some reaction...
    – Lonzak
    Aug 17, 2018 at 8:28
  • 1
    !file.type is now an accepted exclusion pattern (space separated). May 18, 2020 at 18:38

8 Answers 8

137

Note, as of December 5th, 2019, Notepad++ 7.8.2 now supports exclude filters. The help documentation describes exclude filters in the Find in Files tab section.

For example to exclude exe, zip and jar files, your 'find in files' filter will look like this;

*.* !*.exe !*.zip !*.jar

Relevant code change in the GitHub commit.

1
  • 14
    Actually * !*.exe !*.zip !*.jar works, too. It's different, as it'll include files without an extension as well. Jan 30, 2020 at 14:16
39

not that its a GOOD answer, but, what I've found that works is this

*.sql ; *.asp ; *.html ; *.as ; *.mxml

Its definitely not an 'exclude' list, but, by including all the types I need to look at, I get the same result. In my case, I've only got those handfuls of types that I look for often. If your set was wider, this would become even less useful.

0
24

I got a tip from another forum that helped me solve this. Mark the folders you want to exclude as 'hidden'. By default the 'Find in Files' in N++ excludes hidden directories. You can then revert the hidden directories when you're done.

A little tedious, but better than nothing.

4
  • 2
    This blog shellcreeper.com/how-to-exclude-folders-in-notepad-search has a step by step solution to excluding folders by marking them hidden.
    – Asmund
    Aug 17, 2017 at 10:47
  • Does it hurt anything to just leave them hidden, as long as you have Windows Explorer set up to show hidden directories? It took a few minutes to mark everything in my .hg folder as hidden. My search crashed the first time after I did it but worked fine after that.
    – Noumenon
    Oct 13, 2017 at 15:50
  • 1
    In my case, marking my node_modules folder "Hidden" takes about 3 minutes from File Explorer. Any way to speed this up?
    – Super Jade
    May 7, 2019 at 17:24
  • 1
    @Noumenon just change the top level directories to hidden status. Notepad++ will skip the child directories in a hidden folder.
    – Rijo
    May 30, 2019 at 6:10
22

There may be a more elegant way, but you could use PowerShell to get all of the extensions in a folder, and then just remove the ones you don't want. This example gets all of the extensions in the "C:\Program Files\Internet Explorer" folder.

NB: don't forget to surround (Get-ChildItem ... -join ";*" with parentheses.

"*" + ((Get-ChildItem -File -recurse "C:\Users\SomeUser\Documents\Visual Studio 2013\Projects\WindowsService1" | Where {$_.Extension -ne ""}| Select-Object Extension -unique | Sort-Object Extension | Get-Unique -asString  | Select -ExpandProperty Extension | % { $_.ToLower() } | Get-Unique) -join ";*")

This returns:

*.cache;*.config;*.cs;*.csproj;*.exe;*.jmconfig;*.manifest;*.settings;*.sln;*.txt

Then just remove what you don't want.

3
  • 2
    *.bin;*.bmp;*.buildinfo;*.bz2;*.cnf;*.conf;*.conv;*.csm;*.css;*.csv;*.da;*.dat;*.de;*.dic;*.dist;*.doctree;*.dtd;*.en;*.ent;*.eot;*.err;*.es;*.euc-kr;*.exp;*.file;*.fr;*.frm;*.gif;*.gitignore;*.gz;*.h;*.hhvm;*.htaccess;*.html;*.icc;*.ico;*.inc;*.ini;*.ini-development;*.ini-production;*.inv;*.jpg;*.js;*.jshintrc;*.json;*.koi8-;*.lang;*.lib;*.log;*.map;*.md;*.mediawiki;*.mo;*.myd;*.myi;*.new;*.nocoverage;*.ods;*.opt;*.pdb;*.phar;*.php;*.phtml;*.pickle;*.pid;*.pl;*.png;*.properties;*.pt-br;*.py;*.rst;*.sh;*.so;*.sql;*.sty;*.svg;*.sys;*.tpl;*.trg;*.trn;*.ttf;*.txt;*.types;*.utf8;*.var;*.woff;...
    – Marc.2377
    Oct 22, 2016 at 16:10
  • 4
    /\ The above is not comprehensive, I had to cut it due to the character limit for comments in this site. Too bad the char limit for Notepad++ "Filters" is even lower, at precisely 255. So, a "negation" filter would indeed be nice.
    – Marc.2377
    Oct 22, 2016 at 16:15
  • I had to search in files on a W2K3 server, so no powershell, but I ran this script on a Windows 10 PC using a share folder for the W2K3 server and it worked perfectly. Have an upvote.
    – MrVimes
    Apr 16, 2019 at 9:21
22

Perhaps the real answer is don't use NP++ for this. Have you looked at http://www.wingrep.com/features.htm or

Edit: I use https://tools.stefankueng.com/grepWin.html these days

3
  • 6
    This should be the correct answer. For me - finding this page, reading the answers, reading the features.htm in this answer, downloading the software from sourceforge, installing it, and searching for my thing --- finished before the Notepad++ search I started before even going to sourceforge finished. Oct 31, 2016 at 12:27
  • 10
    Disagree. The point was that I am already using Npp to do other tasks in a project. I didn't wish to leave the tool to do a job that could be made easier by a slightly better filter engine. I recognize, though, that others may not have the same constraints :D
    – reidLinden
    Nov 8, 2016 at 17:40
  • 2
    with grepwin, in the text match, type -*.dll to exclude dll files
    – Michael
    Nov 19, 2019 at 17:02
7

Please note tested with Notepad++ v7.8.7

as n00b has answered

This works:

*.* !*.obj

But this does not work!: *.*;!*.obj => searches no files!

on the other hand this does work *.*; !*.obj

1

I just had the same problem and found a 3-step solution:

  1. Search in all files
  2. Copy the result as text in a new Notepad++ tab
  3. Use a regular expression to remove all entries that do not interest you

Here is my RegEx (the two spaces at the start are relevant):

  M:\\.+?\\([^\\]+\.(csproj|dll)|packages\.config|Build\.props) \(\d+ hits?\)([\r\n]+\t.+)+[\r\n]+

All my results where on M:, you will have to adapt the start to what fits your results. If you run a "Replace all" with an empty string it removes all results in files ending with "csproj" or "dll", and also in the files "packages.config" and "Build.props".

1
  • 1
    There are some downsides to this approach. One is that not skipping files can add considerable time to the search. Another one is that, as of 3/2021, some binary files can crash Notepad++ search. Mar 23, 2021 at 19:56
-1

The solution from https://notepad-plus-plus.org/community/topic/10653/exclude-directories-from-the-search/5 is to temporarily set those folders you want to exclude to be 'hidden' folders (hiding just the top level sub-dir is sufficient), and this then stops Notepad++ descending into that sub-directory.

Worked for me just now!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.