Link to home
Start Free TrialLog in
Avatar of sher19
sher19

asked on

How I can loop to create these folders?

I am prompting for 6 different folders to be created.  How can I loop through these to shorten my script?
This was my batch

set /p dir1=Enter the data name:
set /p dir2=Enter the processing folder name:
set /p dir3=Enter the audut folder name:
set /p dir4=Enter the scoring folder name:
set /p dir5=Enter the percentages folder name:
set /p dir6=Enter the finalized folder name:

But I tried to loop it using
for %%x in (data process audit percent final) do (
  set /p dir=Enter the %%x folder name
  md "%dir%"
)

but it isnt working.  please help.
Avatar of sirbounty
sirbounty
Flag of United States of America image

The reasoning has to do with the use of the variable inside your loop.
You would need to use
setlocal enabledelayedexpansion
at the start of your batch to get that to work... ;^)
Avatar of sher19
sher19

ASKER

ok, I try

setlocal enabledelayedexpansion
for %%x in (data process audit percent final) do (
  set /p dir=Enter the %%x folder name
  md "%dir%"
)

but it still doest work for me?
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sher19

ASKER

Thank you that worked
Happy to help - thanx for the grade! :^)