Como criar em lote um intervalo de pastas (000-999) no Windows?

15

Eu preciso criar 1.000 pastas numeradas de 000 a 999 dentro de um diretório. Como posso fazer isso usando cmd (ou seja, a linha de comando do Windows)?

    
por user11955 19.10.2010 / 23:31

2 respostas

25
for /l %i in (0,1,9) do md 00%i
for /l %i in (10,1,99) do md 0%i
for /l %i in (100,1,999) do md %i

Explicação da documentação (por exemplo, digite for /? no prompt de comando):

Runs a specified command for each file in a set of files.

FOR %variable IN (set) DO command [command-parameters]

  %variable  Specifies a single letter replaceable parameter.
  (set)      Specifies a set of one or more files.  Wildcards may be used.
  command    Specifies the command to carry out for each file.
  command-parameters
             Specifies parameters or switches for the specified command.

...

FOR /L %variable IN (start,step,end) DO command [command-parameters]

    The set is a sequence of numbers from start to end, by step amount.
    So (1,1,5) would generate the sequence 1 2 3 4 5 and (5,-1,1) would
    generate the sequence (5 4 3 2 1)
    
por 19.10.2010 / 23:48
-1
@ECHO OFF && CLS

SET /P x=Insert the name of the place: 
SET /P y=Insert de number of the records: 

SET /A start=1
SET /A z=y+1

REM start the loop
:MKDIR

REM make the directory
MKDIR %x%"__"%start%

REM increment by 1
SET /A start=start+1

REM if we're at the end, return
IF %start%==%z% (GOTO :EOF) ELSE (GOTO :MKDIR)
    
por 05.07.2017 / 09:29