Filtering my Find in Files search: help?
-
I need to exclude a set of files from a “Find in Files” search based on filenames containing the string “_bkup”.
The files I am working with look like this:
filename_bkupYYYYMMDD.html filename.html
I need to exclude the first file and include the second file. I cannot filter based on file extensions, which is the approach shown in the Notepad++ documentation.
The following tests failed to exclude the intended files:
*.* ; !*_bkup*.html
*.* ; !*_bkup????????.html
Both of the file masks above return only the files I wish to exclude if I use them in a Windows Explorer search without negation.
If anyone with more experience using this feature could provide some suggestions to put me on the right track it would be much appreciated. Is the search I want possible with this approach or do I need to use regex?
-
I created those two files, with the contents equal to their filename, so I know both have an
a
in them.I searched for
a
with the filter*.* !*_bkup*.html
(no semicolon needed, though it didn’t hurt things)
. This only foundSearch "a" (1 hit in 1 file of 1 searched) C:\Users\peter.jones\Downloads\TempData\nppCommunity\20617\filename.html (1 hit) Line 1: filename.html
If I change the filter to
*.*
, it finds:Search "a" (2 hits in 2 files of 2 searched) C:\Users\peter.jones\Downloads\TempData\nppCommunity\20617\filename.html (1 hit) Line 1: filename.html C:\Users\peter.jones\Downloads\TempData\nppCommunity\20617\filename_bkupYYYYMMDD.html (1 hit) Line 1: filename_bkupYYYYMMDD.html
So, it works for me, as expected.
or do I need to use regex
No, the
filters
box does not use regexBTW: my ? menu, Debug Info:
Notepad++ v7.9.2 (64-bit)
Build time : Dec 31 2020 - 04:01:34
Path : C:\usr\local\apps\notepad++\notepad++.exe
Admin mode : OFF
Local Conf mode : ON
OS Name : Windows 10 Enterprise (64-bit)
OS Version : 1903
OS Build : 18362.1256
Current ANSI codepage : 1252
Plugins : ComparePlugin.dll ExtSettings.dll HexEditor.dll LuaScript.dll MarkdownViewerPlusPlus.dll mimeTools.dll NppConsole.dll NppConverter.dll NppEditorConfig.dll NppExec.dll NppExport.dll NppFTP.dll NppUISpy.dll PreviewHTML.dll PythonScript.dll QuickText.dll RestApiToText.dll TagLEET.dll XMLTools.dll -
@PeterJones Thank you for this.
I am using an older version:
Notepad++ v7.8.1 (64-bit)
Build time : Oct 27 2019 - 22:57:19I’ll update any try again.
-
@Greg-Smith-0 said in Filtering my Find in Files search: help?:
I am using an older version:
Notepad++ v7.8.1 (64-bit)That will do it. The “exclusion” filter wasn’t introduced until v7.8.2 (see release notes). This was also mentioned in the online manual:
-----
As of Notepad++ v7.8.2, you can also exclude certain file patterns by prefixing the filter with a !
----- -
@PeterJones I totally read that but didn’t realize the machine I’m using was out of date!