Question regarding new find-in-files filter excluding ability in version 7.8.2



  • Hello,

    The change log for version 7.8.2 contains the following point

    2. Add find in files filter excluding ability.

    That sounds like a great feature; I’ve been waiting for something like this for a long time. :) But when I open Find in Files, I cannot find anything in the dialog about excluding directories (or file types?) from my search. Am I missing something obvious?



  • @Markus-Kemp109 said in Question regarding new find-in-files filter excluding ability in version 7.8.2:

    Am I missing something obvious?

    Nope, you’re missing something that was not made obvious!

    It doesn’t do anything with directories, but if you want to exclude .bin files from your search, you can do !*.bin, as an example.

    I think there might be a tooltip that makes this more obvious, but I haven’t seen it. :-)



  • Ah, I see. Thanks for the response. Hopefully, one day an exclude-these-directories option will be added to the Find in Files dialog. That would be really great. :)



  • @Alan-Kilborn said in Question regarding new find-in-files filter excluding ability in version 7.8.2:

    !*.bin

    I’ve added a Pull Request to include that example in the Searching > Find in Files docs. It should be merged by this weekend; when it gets released is out of my control.



  • I found the tooltip that provides help on the feature.
    It wasn’t where I expected it.
    I expected it to appear when you hover (and stop moving the mouse) over the box you fill in for the filters, but no, you have to point to (and pause over) the Filters : label itself:

    1e252401-15d7-444c-a518-69c81bb9f0d1-image.png



  • @Markus-Kemp109 said in Question regarding new find-in-files filter excluding ability in version 7.8.2:

    Hopefully…an exclude-these-directories option will be added

    The issue ticket that resulted in the exclude files behavior actually started as a ticket to exclude directories. As of this writing, I think the addition of a directory exclude is being actively worked on.



  • Hello, @markus-kemp109, @peterjones, @alan-kilborn and All,

    Additional points regarding the Filters entry box, of the Replace in Files dialog :

    • If the Filters box is empty , it means *.* ( Trivial ! )

    • The inclusive mask does not need to be the first item. For instance, !*.exe !*.log *.* would scan all files of the given directory ( and, possibly, its sub-dirs ), except for those with extension = exe and log

    • The excluding symbol ! is not a problem if, exceptionally, a filename begins with the ! character. For instance, if the scanned directory contains a file !Test_3.xml the mask !!Test*.* *.xml would scan all xml files whose name do not begin with !Test

    • Note that you cannot just write an exclusive mask, alone ! For instance, the !*.log filter does not scan any file :-(( Personally, I think that !*.log should, implicitly, mean !*.log *.* i. e. it would have scanned all files, except for those with extension = log

    Best Regards,

    guy038



  • @guy038 said in Question regarding new find-in-files filter excluding ability in version 7.8.2:

    The excluding symbol ! is not a problem if, exceptionally, a filename begins with the ! character. For instance, if the scanned directory contains a file !Test_3.xml the mask !!Test*.* *.xml would scan all xml files whose name do not begin with !Test

    But you could have a problem on your hands if you need to search files that match !Test_*.xml, such as !Test_3.xml, !Text_4.xml… :-)



  • @Alan-Kilborn That sounds awesome. Thanks for the info. :)



  • Hi, @markus-kemp109, @peterjones, @alan-kilborn and All,

    Yes, Alan, your’re right about it. I haven’t noticed that, yet !

    So I created four test files Test.txt, Test_2.xml, !Test.txt and !Test_2.xml, from any non-empty xml file, in the folder of my local installation of N++ v7.8.2 :

    Then :

    • Open the Find in Files dialog ( Ctrl + Shift + F )

    • SEARCH Notepad

    • REPLACE $0 ( just in case I run the replacement by mistake ! )

    • DIRECTORY Notepad++ folder

    • Search mode Regular expression

    • FILTERS One of the 6 cases, below

      • *xml => 13 files listed in the Find result panel, not including the empty doLocalConf.xml file

      • *.xml !test*.xml => 11 files listed ( Correct : all but the two Test.txt, Test_2.xml files )

      • *.xml !!test*.xml => 11 files listed ( Correct : all but the two !Test.txt and !Test_2.xml files )

      • test*.xml => 2 files listed ( Correct : only the the two Test.txt, Test_2.xml files )

      • !test*.xml => 0 files listed ( Logic as the inclusive filter is missing ) but incorrect because it should mean, either :

        • All files except for the files Test.txt and Test_2.xml

        • Only the two !Test.txt and !Test_2.xml files

      • !!test*.xml => 0 files listed ( Logic as the inclusive filter is missing ) but incorrect because it should mean, either :

        • All files except for the files !Test.txt and !Test_2.xml

        • Only the two, non-created files, !!Test.txt and !!Test_2.xml


    Note that the forbidden characters, in Microsoft filenames are the nine following symbols :

    \, /, :, *, ?, ", <, > and |

    So, although the case of filenames, beginning with the ! exclamation mark, must be rather rare, I think that using the | symbol to express the negation concept, in the Filters: zone, would have been a more appropriate symbol ;-))

    And of course, an unique syntax |Test*.xml, beginning with the | symbol, would have implicitly meant the syntax *.* |Test*.xml

    Best regards,

    guy038



  • @guy038

    I think that |, while a good choice because it is not allowed in filenames, is a bad choice because C-family programmers are used to it being an “or” operator, which for this application would really be misleading!



  • @alan-kilborn and All,

    Oh, my bad ! Of course, it would not be the best choice as, instead, the ! symbol is curently used, in C, to mean, both, different of ( != ) and the logical NOT operator ( ! )

    Now, I’m stuck : there isn’t any other symbol, which clearly suggests the negation concept ! Of course, we may rename any file beginning with the ! symbol but, finally, the best choice would be a new Excluding: zone ;-)) in the Find in Files dialog, wouldn’t it be ?

    BR

    Guy038



  • I think it was decided that ! usage as the first character in a filename was rare enough to not cause a real problem here. Adding additional GUI elements is problematic because it takes up precious screen area and then has to be translated into all kinds of languages. Not huge problems, but I think the current prefix of ! is pretty reasonable, so I would vote to leave it the way it is.


Log in to reply