0

I need to create folders named 0001 to 1000 using a batch command. Folder names should be all 4 digits, ie: 0001, 0002, 0999 - 1000.

I've already tried this command line:

for /L %%g in (1,1,1000) do (md %%g)
3
  • 3
    Welcome to Super User. When you tried the command in the question, what was the result?
    – fixer1234
    Jan 14, 2019 at 6:14
  • Use 4 separate commands for to create folders 0001-0009, 0010-0099, 0100-0999 and 1000 respectively. It is the simplest solution I think.
    – Akina
    Jan 14, 2019 at 7:53
  • it created folder 1,2,3 and so on...but what i need is 4 digits standard in folder name.. Jan 14, 2019 at 7:53

1 Answer 1

0

You could also try the following (in a batch file):

setlocal enabledelayedexpansion
for /l %%i in (1,1,1000) do set n=0000%%i& echo !n:~-4!

This gives

0001
0002
0003
...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.