Community
    • Login

    Find files that don't contain

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    7 Posts 3 Posters 4.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Craig McFarlaneC Offline
      Craig McFarlane
      last edited by

      Hi Guys.

      What expression would I need to find all files in a folder that don’t contain say

      Add-Content -path *.cfg -Value ‘input_overlay_enable = “true”’

      I have about 1000 files and I know some of them won’t have that line present. I just don’t know which ones.

      Thanks in advance.

      Alan KilbornA 2 Replies Last reply Reply Quote 0
      • Alan KilbornA Offline
        Alan Kilborn @Craig McFarlane
        last edited by Alan Kilborn

        @Craig-McFarlane

        Your question is kind of similar to this old one: https://community.notepad-plus-plus.org/topic/16141/find-content-in-files-and-rename-delete-files-not-containing-content

        As well as this one: https://community.notepad-plus-plus.org/topic/14870/regex-find-all-files-that-do-not-contain-some-words

        1 Reply Last reply Reply Quote 1
        • Alan KilbornA Offline
          Alan Kilborn @Craig McFarlane
          last edited by

          @Craig-McFarlane

          However, if it is too much reading for you–I just read it, there’s A LOT there–then this might work for your situation:

          Find what box: (?s)\A(?:(?!\QAdd-Content -path *.cfg -Value 'input_overlay_enable = "true"'\E).)+\z

          Craig McFarlaneC 1 Reply Last reply Reply Quote 2
          • Craig McFarlaneC Offline
            Craig McFarlane @Alan Kilborn
            last edited by

            @Alan-Kilborn

            Thanks mate. No its not to much reading at all. Simply pointing me in the right direction would have been a sufficient answer.

            Thank you for the time it took you.

            1 Reply Last reply Reply Quote 1
            • guy038G Online
              guy038
              last edited by guy038

              Hello, @craig-mcfarlane, @alan-kilborn and All,

              Certainly, the regex, below, does work properly in the majority of cases :

              SEARCH (?s-i)\A(?:(?!\QYour Expression\E).)+\z

              However, when files scanned have a size greater than 8 Mb, about, this regex may fail and wrongly matches a file which does contain your specific expression ! I did some tests with such a file, containing the string Your expression once only !


              If so, here is a quicker and safer regex which is able to handle huge files. I personally tested a file of 56 Mb and 2,000,000 lines, without any trouble ! This file contained only a single line with the string Your expression ;-))

              SEARCH (?s-i)\A(?!.*\QYour Expression\E).+

              => You’ll get your expected list of files which do not contain the string Your expression, with this exact case ;-))

              Best Regards,

              guy038

              P.S. :

              In order to get the list of the files, with their full path, displayed in the Find result panel, pasted into a new tab, follow these steps :

              • Right-click on any zone of the Find result panel

              • Select the Select all option

              • Hit the Ctrl + C shortcut ( do not use the Copy option ! )

              • Hit the Ctrl + N shortcut to open a new N++ tab

              • Hit the Ctrl + V shortcut to paste the results, into this new tab

              • Finally, perform the following regex S/R, below :

                • SEARCH ^(?!\x20\x20).*\R|\Q (1 hit)\E$

                • REPLACE Leave EMPTY

              Craig McFarlaneC 1 Reply Last reply Reply Quote 4
              • Craig McFarlaneC Offline
                Craig McFarlane @guy038
                last edited by Craig McFarlane

                @guy038

                Thank you so much for a helpful and constructive reply. I am learning and this really helped a lot. Thanks for a clear explanation.

                1 Reply Last reply Reply Quote 0
                • Alan KilbornA Alan Kilborn referenced this topic on
                • Alan KilbornA Offline
                  Alan Kilborn
                  last edited by

                  Here’s a real feature request for making “Find files that don’t contain” a part of standard Notepad++: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/15680

                  1 Reply Last reply Reply Quote 2

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • First post
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors