Reputation: 102
I'm trying to run the following windows batch file:
@echo off
CALL workon my_env
CD C:\scripts
SET DataPath = C:\user\data
SET SavePath = C:\results
FOR %DataQuantity IN ( 100 75 60 50 40 33 25 10 ) DO (
FOR %Subject IN ( 1 2 4 5 6 7 8 9 ) DO (
python classifier.py DataQuantity Subject DataPath SavePath
python detector.py DataQuantity Subject DataPath SavePath
python compiler.py DataQuantity Subject DataPath SavePath
)
)
I want to three python scripts with different arguments using nested for loops. There are four arguments passed to each of the python scripts, out of which two are set beforehand, and two come form the for loops.
But I'm getting the following error:
"DataQuantity was unexpected at this time"
Upvotes: 1
Views: 1673
Reputation: 381
You are missing percent char:
FOR %%B IN ( 100 75 60 50 40 33 25 10 ) DO (
FOR %%S IN ( 1 2 4 5 6 7 8 9 ) DO (
python classifier.py %%B %%S %DataPath% %SavePath%
python detector.py %%B %%S %DataPath% %SavePath%
python compiler.py %%B %%S %DataPath% %SavePath%
)
)
In for use %%
and to use setted variable use %VAR%
.
Upvotes: 0
Reputation: 102
@echo off
CALL workon my_env
CD C:\scripts
SET DataPath=C:\user\data
SET SavePath=C:\results
FOR %%q IN ( 100 75 60 50 40 33 25 10 ) DO (
FOR %%s IN ( 1 2 4 5 6 7 8 9 ) DO (
python classifier.py %%q %%s %DataPath% %SavePath%
python detector.py %%q %%s %DataPath% %SavePath%
python compiler.py %%q %%s %DataPath% %SavePath%
)
)
Following were fixed:
SET DataPath=C:\user\data
%%q
%DataPath%
Upvotes: 3