|
Answer» Hi there.
I am attempting to use a batch file to automatically create incremented folders in a subdirectory based on the last folder name in the subfolder.
eg. I have a folder called C:\Data and it has subfolders called v01, v02, v03, v04 etc What I want to do look in C:\Data and create a subfolder that is +1 from the previously created folder.
Any help would be GREATLY appreciated.Something like this may work on your MACHINE:
Code: [Select]@echo off for /l %%x in (1,1,9) do ( if not exist c:\data\nul (md c:\data\v0%%x & goto :eof) ) for /l %%x in (10,1,10000) do ( if not exist c:\data\nul (md c:\data\v%%x & goto :eof) ) The range of the code is 1 to 10,000. Feel free to CHANGE it.
Fantastic, thanks for that Sidewinder.
Now would you know how to incorporate the newly created folder into a SET variable so that I can then use this new folder to COPY my files into.
Currently I manually change the variable that I have each time I create a new folder. I am using -
SET Dump=C:\Data\v01 :: I then change this to v02, v03, v04 etc, you get the picture.
Once again thanks for the help.Code: [Select]@echo off for /l %%x in (1,1,9) do ( if not exist c:\data\v0%%x\nul ( set Dump=c:\data\v0%%x md c:\data\v0%%x goto next ) ) for /l %%x in (10,1,10000) do ( if not exist c:\data\v%%x\nul ( set Dump=c:\data\v%%x md c:\data\v%%x goto next ) ) :next
The internal label should make it easier to incorporate the snippet into your own code.
Perfect. Does exactly what I wanted it to do.
Thanks again
|