Jump to content

Batch for creating sequence of folders


Recommended Posts

Hi everyone,

I would like to create several folders in a row like 01, 02, 03 ... n. The batch command should stop after creating folder n. It would be also nice if I could specify a prefix for the folders. Can some please help to create such a batch file?

Thanks in advance

Kukris

Link to comment
Share on other sites


Perhaps something along these lines may help

@ECHO OFF &SETLOCAL ENABLEEXTENSIONS
SET "n=14" &SET "prefix=backups_"
FOR /L %%? IN (1,1,%n%) DO IF %%? LSS 10 (IF NOT EXIST %prefix%0%%? MD %prefix%0%%?) ELSE (IF NOT EXIST %prefix%%%? MD %prefix%%%?)
ENDLOCAL &GOTO :EOF

Just change the prefix from backups_ to your preferred choice and set your n to the appropriate value for the last number in the sequence, I used 14, for this example.

Edited by Yzöwl
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.


×
×
  • Create New...