I try to run a simple batch script as shown below. Basically I want to visit each sub-directory in a given directory and run a gmake command.
echo %USER_DEF_VAR%
cd %USER_DEF_VAR%\topLevelDir
for /D %G in ("%USER_DEF_VAR%\topLevelDir\*") do (
cd %G
gmake clean
gmake
)
If I run this script on a command line, it works fine. But when I put this in a .bat script it throws me an error saying
do ( was unexpected at this time.
I have tried removing spaces wherever possible as suggested here - nested For loop in batch file error: Do was unexpected at this time
I'm still facing the same issue.
In a batch script you have to double the %
:
for /D %%G in ("%USER_DEF_VAR%\topLevelDir\*") do (
cd "%%~G"
...
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With