Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Find files that don't contain

    Help wanted · · · – – – · · ·
    3
    6
    458
    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 McFarlane
      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 Kilborn 2 Replies Last reply Reply Quote 0
      • Alan Kilborn
        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 Kilborn
          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 McFarlane 1 Reply Last reply Reply Quote 2
          • Craig McFarlane
            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
            • guy038
              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 McFarlane 1 Reply Last reply Reply Quote 3
              • Craig McFarlane
                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
                • First post
                  Last post
                Copyright © 2014 NodeBB Forums | Contributors