Solved

How I can loop to create these folders?

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
The viewer will learn how to dynamically set the form action using jQuery.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

808 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