Solved

DOS Batch files :  looping

Posted on 2007-03-22
2
345 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

18 Experts available now in Live!

Get 1:1 Help Now