Possible Duplicate:
how to write bat file to process all files include sub directory, and output them with the same directory structure to another directory?
There are several questions that are asking how to go into sub directorys with batch script but most of the time they just list files or do some other quite complex stuff that I don’t need in this case.
I have CLI program that I want to process every *.dat file in all sub directories of the current dir. It doesn’t have to include the home dir. I’m pretty sure that this could be done in a simple way with /r but all my trials ended in errors. What I tried for example:
for /r path %%var in (*.dat) do process.exe -8 %%var
All I get is a syntax error and I don’t know why.
Your problem is your FOR variable name – they must be a single character, and they are case sensitive.
You also should quote the variable when used as an argument to a program because the file name might contain spaces or special characters.
If you want to recursively process all .dat files from within the current directory, then the /R option does not need a path specifier.
You can run the above from the command line, but then you only use one %