Need a neater way to make the next directory
Posted: 01 Oct 2006 20:26
I have a batch file that sends files to a history folder in a very long drawn out fashion using if exist do that. if that exist do this. line after line.
I am looking for a way to determine the last folder created *.001 or *.* then make the next folder *.002 out to 50 folders.
I have a name convention for the folders that works well I just need to find a better way for getting from folder *.01 to folder *.050
here is a sample of what I do now:
:mkhistory
::
:: Stores last 10 batch uploads in history folder to provide a way to
:: recover in the event some data is lost and data from guns has already
:: been removed.
::
cls
if exist %SystemDrive%\WindowsPC\erbt\BAR* goto mkhistory1
if not exist %SystemDrive%\WindowsPC\erbt\BAR* goto end
:mkhistory1
cls
if exist %SystemDrive%\WindowsPC\erbt\history\*.**1 goto mkhistory2
if /I not exist %SystemDrive%\WindowsPC\erbt\history\*.**1 goto mk1
:mk1
cls
MKDIR %SystemDrive%\WindowsPC\erbt\history\%mm%%dd%%hh%%min%%ss%.001
move /y %SystemDrive%\WindowsPC\BAR*.* %SystemDrive%\WindowsPC\erbt\history\%mm%%dd%%hh%%min%%ss%.001\
goto end
:mkhistory2
cls
if exist %SystemDrive%\WindowsPC\erbt\history\*.**2 goto mkhistory3
if /I not exist %SystemDrive%\WindowsPC\erbt\history\*.**2 goto mk2
:mk2
cls
MKDIR %SystemDrive%\WindowsPC\erbt\history\%mm%%dd%%hh%%min%%ss%.002
move /y %SystemDrive%\WindowsPC\BAR*.* %SystemDrive%\WindowsPC\erbt\history\%mm%%dd%%hh%%min%%ss%.002\
goto end
:mkhistory3
cls
if exist %SystemDrive%\WindowsPC\erbt\history\*.**3 goto mkhistory4
if /I not exist %SystemDrive%\WindowsPC\erbt\history\*.**3 goto mk3
:mk3
cls
MKDIR %SystemDrive%\WindowsPC\erbt\history\%mm%%dd%%hh%%min%%ss%.003
move /y %SystemDrive%\WindowsPC\BAR*.* %SystemDrive%\WindowsPC\erbt\history\%mm%%dd%%hh%%min%%ss%.003\
goto end
:mkhistory4
cls
if exist %SystemDrive%\WindowsPC\erbt\history\*.**4 goto mkhistory5
if /I not exist %SystemDrive%\WindowsPC\erbt\history\*.**4 goto mk4
:mk4
on and on and on
I am looking for a way to determine the last folder created *.001 or *.* then make the next folder *.002 out to 50 folders.
I have a name convention for the folders that works well I just need to find a better way for getting from folder *.01 to folder *.050
here is a sample of what I do now:
:mkhistory
::
:: Stores last 10 batch uploads in history folder to provide a way to
:: recover in the event some data is lost and data from guns has already
:: been removed.
::
cls
if exist %SystemDrive%\WindowsPC\erbt\BAR* goto mkhistory1
if not exist %SystemDrive%\WindowsPC\erbt\BAR* goto end
:mkhistory1
cls
if exist %SystemDrive%\WindowsPC\erbt\history\*.**1 goto mkhistory2
if /I not exist %SystemDrive%\WindowsPC\erbt\history\*.**1 goto mk1
:mk1
cls
MKDIR %SystemDrive%\WindowsPC\erbt\history\%mm%%dd%%hh%%min%%ss%.001
move /y %SystemDrive%\WindowsPC\BAR*.* %SystemDrive%\WindowsPC\erbt\history\%mm%%dd%%hh%%min%%ss%.001\
goto end
:mkhistory2
cls
if exist %SystemDrive%\WindowsPC\erbt\history\*.**2 goto mkhistory3
if /I not exist %SystemDrive%\WindowsPC\erbt\history\*.**2 goto mk2
:mk2
cls
MKDIR %SystemDrive%\WindowsPC\erbt\history\%mm%%dd%%hh%%min%%ss%.002
move /y %SystemDrive%\WindowsPC\BAR*.* %SystemDrive%\WindowsPC\erbt\history\%mm%%dd%%hh%%min%%ss%.002\
goto end
:mkhistory3
cls
if exist %SystemDrive%\WindowsPC\erbt\history\*.**3 goto mkhistory4
if /I not exist %SystemDrive%\WindowsPC\erbt\history\*.**3 goto mk3
:mk3
cls
MKDIR %SystemDrive%\WindowsPC\erbt\history\%mm%%dd%%hh%%min%%ss%.003
move /y %SystemDrive%\WindowsPC\BAR*.* %SystemDrive%\WindowsPC\erbt\history\%mm%%dd%%hh%%min%%ss%.003\
goto end
:mkhistory4
cls
if exist %SystemDrive%\WindowsPC\erbt\history\*.**4 goto mkhistory5
if /I not exist %SystemDrive%\WindowsPC\erbt\history\*.**4 goto mk4
:mk4
on and on and on