Increment the folder number

March 29, 2011 at 13:14:22
Specs: Windows XP
Everytime i run the batch script, new folder with the increment number should be created.

Say for example for the first time i run the batch script, folder is created with the the name "1.1".

Next time for the new folder name should be "1.2".

Please help me to create the batch script for the above requirement.


See More: Increment the folder number

Report •

#1
March 29, 2011 at 19:38:24
The below should create:

1.1 - 1.9
2.0 - 2.9
.....
10.0 - 10.9
....

@echo off
set fldr=11
:loop
if exist "%fldr:~0,-1%.%fldr:~-1%" (
    set /a fldr+=1
    goto loop
)
set fldr=%fldr:~0,-1%.%fldr:~-1%
md "%fldr%"
echo created "%fldr%"
pause


Report •

#2
March 30, 2011 at 13:52:17
Thanks for the reply...Its perfectly working.

But, If i want the folder number to start with 11.2.0...followed by 11.2.1....
Wr i need to update the script ?


Report •

#3
March 30, 2011 at 17:24:45
@echo off
set fldr=1120
:loop
if exist "%fldr:~0,-2%.%fldr:~-2,1%.%fldr:~-1%" (
    set /a fldr+=1
    goto loop
)
set fldr=%fldr:~0,-2%.%fldr:~-2,1%.%fldr:~-1%
md "%fldr%"
echo created "%fldr%"


Report •
Related Solutions


Ask Question