• Login
Community
  • Login

Find files that don't contain

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
7 Posts 3 Posters 2.5k 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.
  • C
    Craig McFarlane
    last edited by Mar 30, 2020, 5:32 PM

    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.

    A 2 Replies Last reply Mar 30, 2020, 6:02 PM Reply Quote 0
    • A
      Alan Kilborn @Craig McFarlane
      last edited by Alan Kilborn Mar 30, 2020, 6:03 PM Mar 30, 2020, 6:02 PM

      @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
      • A
        Alan Kilborn @Craig McFarlane
        last edited by Mar 30, 2020, 7:10 PM

        @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

        C 1 Reply Last reply Mar 30, 2020, 8:44 PM Reply Quote 2
        • C
          Craig McFarlane @Alan Kilborn
          last edited by Mar 30, 2020, 8:44 PM

          @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
          • G
            guy038
            last edited by guy038 Mar 31, 2020, 2:21 PM Mar 31, 2020, 1:57 PM

            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

            C 1 Reply Last reply Mar 31, 2020, 6:31 PM Reply Quote 4
            • C
              Craig McFarlane @guy038
              last edited by Craig McFarlane Mar 31, 2020, 6:33 PM Mar 31, 2020, 6:31 PM

              @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
              • A Alan Kilborn referenced this topic on Jun 2, 2023, 5:26 PM
              • A
                Alan Kilborn
                last edited by Oct 6, 2024, 10:50 AM

                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
                1 out of 7
                • First post
                  1/7
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors