I’ve done some small batch files before, but never any that required file names being read in a folder.
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 don’t know how to make it search each file in a folder, and those file names change on a daily basis.
in your problem statement you said all of these files are
.txtfiles. So I would recommend using afor loopto loop through each of the.txtfiles in the directory, and then usefindstrto search for the intended string. The code I posted below will work in such a manner. Essentially it changes the directory to the desktop (or wherever your files are located), then loops through each.txtfiles and searches for the string. Thefindstroutput is redirected tonul(for faster processing) and if this is successful, the.txtfile is moved toC:\Users\Desktop\SuccessFolder, otherwise this file is placed inC:\Users\Desktop\FailureFolder. (Keep in mind the search"string", original location, and 2 folder locations still need to be set) I believe this code should work for what you are trying to accomplish. Let me know if any changes need to be made to the code =]