Solved

How I can loop to create these folders?

Posted on 2007-03-24
5
181 Views
Last Modified: 2010-04-16
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.
0
Comment
Question by:sher19
  • 3
  • 2
5 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18786991
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... ;^)
0
 

Author Comment

by:sher19
ID: 18786994
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?
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18786997
Try this version...

setlocal enabledelayedexpansion
for %%a in (data processing audit percentages finalized) do call :process %%a
goto :eof

:process
set /p myDir=Enter the %1 folder name:
md "%mydir%"
set mydir=
0
 

Author Comment

by:sher19
ID: 18787002
Thank you that worked
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18787003
Happy to help - thanx for the grade! :^)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question