Community
    • Login

    search list values in 50+ files

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 631 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.
    • Tino Salskov LarsenT
      Tino Salskov Larsen
      last edited by

      I have a list of values, 6000+.
      Can I somehow search for those values in 50+ different files?

      Alan KilbornA mkupperM 2 Replies Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Tino Salskov Larsen
        last edited by Alan Kilborn

        @Tino-Salskov-Larsen said:

        I have a list of values, 6000+. Can I somehow search for those values in 50+ different files?

        First, the answer here is likely to be “not great”. :-(

        Second, I’d ask if the “50+ different files” are all in one subdirectory (where it is only and all the files to search), or are we really talking about a second list here, where you have a sequence of files-to-search in the list? Example:

        C:\folder1\subfolderA\file1.txt
        C:\folder1\subfolderA\file2.txt
        C:\folder1\subfolderB\file3.txt
        C:\folder2\file4.txt
        etc

        1 Reply Last reply Reply Quote 1
        • mkupperM
          mkupper @Tino Salskov Larsen
          last edited by mkupper

          @Tino-Salskov-Larsen I normally do that from the command line. Notepad++'s search can’t use a list of thousands of values.

          Let’s say that the values.txt file has a list of values, one per line. From a command prompt run:

          for /f "usebackq delims=" %i in ("values.txt") do findstr /c:"%~i" file1 file2 ...
          
          • If you use this in a .cmd or .bat file then the %i and %~i need to have two percent signs or %%i and %%~i
          • The usebackq part is optional and allows you to use “quotes” around the path to your values.txt file.
          • Normally the for command with the /f option supports multiple values on each line of the values.txt file with the values separated by spaces, commas, etc. We don’t want this and so I use delims= to disable the list of delimiter characters so that it’s one value per line.
          • The findstr command has command line arguments for scanning sub-directories, dealing with lists of files or directories, etc. Use findstr /? to see the options.
          • findstr’s file name processing is decent and allows for wildcards. You can have as many files or folders on the list or set up files that contain lists of files or folders to scan.

          Findstr supports very basic regular expressions meaning your list of values can be regular expressions. The findstr /? help page has a section called “Regular expression quick reference” that implies there would be more possible regular expression things than the ones listed but I’m pretty sure the only features findstr’s regular expression engine supports are the ones listed in the quick reference. There is no + operator for example though that can be simulated by using aa* with findstr rather than a+ that works with most regular expression engines.

          You did not say what your potential values are. The method outlined above may not work if they contain “double quotes” etc. There are for and findstr tricks to get around those issues but that’s getting far beyond the scope of this forum.

          Alan KilbornA 1 Reply Last reply Reply Quote 2
          • Alan KilbornA
            Alan Kilborn @mkupper
            last edited by

            @mkupper said in search list values in 50+ files:

            I normally do that from the command line. Notepad++'s search can’t use a list of thousands of values.

            You should have stopped after those 2 sentences.
            Please don’t present detailed non-Notepad++ solutions to questions posed on this site.
            This site is for discussion of Notepad++ related topics, only.

            If you feel like you want to suggest a non-Notepad++ solution to something, perhaps the best reply is suggesting some keywords for an internet search the poster could do to arrive at some help.

            1 Reply Last reply Reply Quote 2
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors