Search code examples
batch-filecmdcopyxcopy

How to duplicate one directory/folder and its contents 100 times?


I need to know how to make 100 copies of the same folder and its sub-folders.

I know how to copy once with the following:

for /l %i in (1,1,1) do xcopy /i /e "folder 1" "folder 2"

Is there a way to make this code run 100 times and make 100 copies of folder 1 and its contents?


Solution

  • Just try to increase the %L variable in your for /L loop, from 1,1,1 to 1,1,100...

    • In command line:
    for /L %L in (1,1,100)do %__APPDIR__%xcopy.exe /i /e "folder 1" "folder %L"
    

    @echo off && for /L %%L in (1,1,100)do %__APPDIR__%xcopy.exe /i /e "folder 1" "folder %%L"
    

    your cmd:  (     1,        1,     1 ) == 1, 1, 1 
        loop:  ( start, increase, until ) == x,+1, y
    you need:  (     1,        1,   100 ) == 1, 1, 100