Solved

How I can loop to create these folders?

Posted on 2007-03-24
5
183 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

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…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn how to dynamically set the form action using jQuery.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

617 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