lundi 22 février 2016

If statement inside For loop in batch script

I am developing a batch script to make changes to multiple servers that may or may not contain a particular subfolder under D:\apps\domain. There are multiple combinations of possible domain subfolders. My logic requires: if domain\folder1 exists then do command1 if domain\folder2 exists then do command2 and so on

I am using the following...

for /f "tokens=*" %%Z in ('dir /a:D /b "D:\apps\domain"') do ( if %%Z="PGBWAHD_NA" command1

but get syntax errors on first IF statement.
Error message .... =PGBWAHD_NA was unexpected at this time. D:\apps\hawk_schtasks>if /I %Z=PGBWAHD_NA The subfolder PGBWAHD_NA does exist, but the script errors and quits.

Aucun commentaire:

Enregistrer un commentaire