Jump to content

Recommended Posts

Posted

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


Posted (edited)

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...