I have been searching the internet for 2 hours now and cant find what I am looking for.
Basically, I want to script searching the entire drive for specific files.
Best way I found to do this is by outputting all folders and files to an output file with dir /s
. Then, I use findstr
to compare my search parameters file against the dir
output. The search works...but it only puts out the specific thing it found.
Results I get are
notepad.exe
download.bat
Results I want are
c:\windows\notepad.exe
c:\download.bat
. . .Or if you have code that will just search the drive for said things, then thats perfect. I'd actually want just the path, instead of the whole line found in dir /s
.
either way, heres some code I was playing with.
@echo off
set dir_out=c:\dir_output.txt
set search=C:\in.txt
set out=c:\Match_Output.txt
echo delelting old %search% file
if exist %search% del %search% /f
echo delelting old %out% file
if exist %out% del %out% /f
echo delelting old %dir_out% file
if exist %dir_out% del %dir_out% /f
echo creating new %search% file
echo notepad.exe >> %search%
echo download.bat >> %search%
echo changing to root directory
cd\
echo outputing entire c:\ into log file
dir /s >> %dir_out%
echo matching log file
findstr /ixg:%search% %dir_out% >> %out%