Solved

DOS Batch files :  looping

Posted on 2007-03-22
2
367 Views
Last Modified: 2010-08-05
@echo off
cls

set %File_Name%=%1

mkdir C:\Server\ticketing\%File_Name%      
mkdir C:\Server\ticketing\class\%File_Name%
mkdir C:\Server\ticketing\class\type\%File_Name%      


Here I am creating folder by entering argument from command line (C:\>createfolders.bat file1) ,  here I am able to create on folder at a time. But I want to create more then one folder at a time by entering more arguments like C:\>createfolders.bat file1 file2 file3.  Is this possible, if it can how?
0
Comment
Question by:MADHU_N
[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
2 Comments
 
LVL 30

Accepted Solution

by:
SteveGTR earned 500 total points
ID: 18776568
Try this:

@echo off

:START

if "%~1"=="" goto :EOF

mkdir "C:\Server\ticketing\%~1"
mkdir "C:\Server\ticketing\class\%~1"
mkdir "C:\Server\ticketing\class\type\%~1"

shift
goto START

Good Luck,
Steve
0
 
LVL 5

Expert Comment

by:GirardAndrew
ID: 18783752
@echo off
cls

:1st
set %File_Name%=%1
mkdir C:\Server\ticketing\%File_Name%
mkdir C:\Server\ticketing\class\%File_Name%
mkdir C:\Server\ticketing\class\type\%File_Name%

:2nd
set %File_Name%=%2
mkdir C:\Server\ticketing\%File_Name%
mkdir C:\Server\ticketing\class\%File_Name%
mkdir C:\Server\ticketing\class\type\%File_Name%

:3rd
set %File_Name%=%3
mkdir C:\Server\ticketing\%File_Name%
mkdir C:\Server\ticketing\class\%File_Name%
mkdir C:\Server\ticketing\class\type\%File_Name%
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Batch / VB Script: copy rename and zip folders. 28 219
robocopy 6 70
How to run multiple lines in a batch file 4 91
msdos loop until a variable value changes 5 50
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
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…

733 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