Solved

How I can loop to create these folders?

Posted on 2007-03-24
5
173 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

758 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now