I have a folder with ~20,000 files in multiple subfolders. The files have varying extensions, but their content is all text. I also have a text list of ~500 names. I'd like to search all the files for each name in the text list, one at a time, for the purpose of determining if that name appears in any of the files.
The desired output is a text list of ~500 lines (or however many names were searched), each with a 1 (if the name was found, regardless of how many times) or a 0 (if not). The order of this file would match the input text list.
e.g.,
searchstring.txt
nameA
nameB
nameC
searchfolder
subfolder1
file.abc (references name A)
file2.xyz (no references)
subfolder2
file.xyz (no references)
file3.xyz (references name A)
subfolder3
file4.abc (no references)
file5.xyz (references name A, name C)
result.txt
1
0
1
Ideally the search would be called be with a batch file with commands available on Windows 7 and up. The environment may not have Admin permissions.
For the information you have provided in your edit, the following single line may work for you.
As a batch-file:
@For /F UseBackDelims^=^ EOL^= %%A In ("searchstring.txt")Do @(FindStr /LIMPS "%%~A" "searchfolder\*.*">Nul&&(Echo 1)||Echo 0)>>"result.txt"
Entered at the cmd prompt:
For /F UseBackDelims^=^ EOL^= %A In ("searchstring.txt")Do @(FindStr /LIMPS "%~A" "searchfolder\*.*">Nul&&(Echo 1)||Echo 0)>>"result.txt"