Solved Batch File, search all files in folder, then sort

October 17, 2012 at 10:09:14
Specs: Server 2008, 8 gig
I need a batch file that can sort a folder for me.

I need it to look into a folder, search each text file, if it contains a "string", then move it into an accepted folder, if not, move it into a rejected folder.

Any ideas how to tackle this?

I have used something as follows for finding text before.

find /c "string" file
if %errorlevel% equ 1 goto

I'm sure I could manipulate the search, butI don't know how to make it search each file in a folder, and those file names change on a daily basis.


See More: Batch File, search all files in folder, then sort

Report •


#1
October 17, 2012 at 13:35:24
Untested:
FOR /F "DELIMS=" %%a IN ('FINDSTR /M "string" *') DO MOVE "%%a" accepted
MOVE * rejected

How To Ask Questions The Smart Way


Report •

#2
October 18, 2012 at 07:06:56
✔ Best Answer
for %%j in (*.txt) do find "string" "%%j" >nul && move "%%j" accepted || move "%%j" rejected


Report •

Related Solutions


Ask Question