search list values in 50+ files
-
I have a list of values, 6000+.
Can I somehow search for those values in 50+ different files? -
@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 -
@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 usedelims=
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. Usefindstr /?
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 usingaa*
with findstr rather thana+
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
andfindstr
tricks to get around those issues but that’s getting far beyond the scope of this forum. - If you use this in a .cmd or .bat file then the
-
@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.