Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DOS Batch files :  looping

Posted on 2007-03-22
2
Medium Priority
?
380 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 2000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

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…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

688 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