batchfile script to create folders

C

Chip

Hi,

I need to create folders ch000,ch001....ch119 ( total 121
floders) under a folder. It is painful to create manually.
Can any one write a piece of .BAT code to do the job.

Thanks in advance

Chip
 
R

Ray at

You can use a for loop for this. I don't know that this is the quickest way
to deal with the 0 padding, but it'll work.

REM USING: FOR /L %variable IN (start,step,end) DO command
[command-parameters]

for /l %%f in (0,1,9) do (mkdir ch00%%f)
for /l %%f in (10,1,99) do (mkdir ch0%%f)
for /l %%f in (100,1,121) do (mkdir ch%%f)

Ray at work
 
R

Ray at

That last look should have ended at 119 or 120, not 121. You said you want
121 directories, so that would end at 120, but you have 119 as the last one
below, so just adjust it accordingly.

Ray at work
 
C

Chip

Hi Ray,

Thank you verymuch. It worked excellently. I too wish to
write my own Batch files. Can you please guide me a good
book or resource to start with and can take me indepth.

Thanks in Advance

Chip
-----Original Message-----
You can use a for loop for this. I don't know that this is the quickest way
to deal with the 0 padding, but it'll work.

REM USING: FOR /L %variable IN (start,step,end) DO command
[command-parameters]

for /l %%f in (0,1,9) do (mkdir ch00%%f)
for /l %%f in (10,1,99) do (mkdir ch0%%f)
for /l %%f in (100,1,121) do (mkdir ch%%f)

Ray at work

Hi,

I need to create folders ch000,ch001....ch119 ( total 121
floders) under a folder. It is painful to create manually.
Can any one write a piece of .BAT code to do the job.

Thanks in advance

Chip


.
 
R

Ray at

Here are links that Austin Horst posted the other day:

http://www.microsoft.com/technet/tr...chNet/prodtechnol/winxppro/proddocs/batch.asp

http://www.robvanderwoude.com/

http://www.computerhope.com/batch.htm

http://www.ericphelps.com/batch/

http://www.labmice.net/articles/batchcmds.htm

http://gatsby.tafe.tas.edu.au/batch/

http://www.tnd.com/camosun/elex130/dosbatchtutor1.html

http://www.chebucto.ns.ca/~ak621/DOS/BatBasic.html

http://www.merlyn.demon.co.uk/batfiles.htm

Ray at work


Chip said:
Hi Ray,

Thank you verymuch. It worked excellently. I too wish to
write my own Batch files. Can you please guide me a good
book or resource to start with and can take me indepth.

Thanks in Advance

Chip
-----Original Message-----
You can use a for loop for this. I don't know that this is the quickest way
to deal with the 0 padding, but it'll work.

REM USING: FOR /L %variable IN (start,step,end) DO command
[command-parameters]

for /l %%f in (0,1,9) do (mkdir ch00%%f)
for /l %%f in (10,1,99) do (mkdir ch0%%f)
for /l %%f in (100,1,121) do (mkdir ch%%f)

Ray at work

Hi,

I need to create folders ch000,ch001....ch119 ( total 121
floders) under a folder. It is painful to create manually.
Can any one write a piece of .BAT code to do the job.

Thanks in advance

Chip


.
 
M

Matthias Tacke

at said:
You can use a for loop for this. I don't know that this is the quickest way
to deal with the 0 padding, but it'll work.

REM USING: FOR /L %variable IN (start,step,end) DO command
[command-parameters]

for /l %%f in (0,1,9) do (mkdir ch00%%f)
for /l %%f in (10,1,99) do (mkdir ch0%%f)
for /l %%f in (100,1,121) do (mkdir ch%%f)

No better solution, but a more generic way to get the leading zero's

@echo off & setlocal EnableExtensions EnableDelayedExpansion
for /l %%f in (0,1,119) do (set n=000%%f
echo mkdir ch!n:~-3!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top