How to use Robocopy to copy a folder structure into all (sub)folders located under one directory?

Is there anyway for me to quickly take an empty folder structure I have created on my desktop and copy it to 488 other folders all located on a network drive but in the same folder?

My primary difficulty with this is that I want the folder structure I have created to be placed in the sub folders of a networked folder. There are 488 folders where my structure must be copied to. They all contain additional folders and files themselves, which I do not want to have any effect on. Is there a way to set robocopy destination folder to a 1 level lower or deeper than the destination folder? Similar to /LEV:n but reversed essentially?

I have seen some postings mentioning recursion in what I believe to be are similar situations but I do not know how to execute a recursive function if that is possible.

Answer

I am not quite sure if I understand every aspect of your question, but here we go.

Save this code to a CMD file and customize the source, destination and robocopy.exe path where destination means the root folder which contains your 488 subfolders.

@echo off
SET "source=C:UserszsmallDesktopAttachment Structure"
SET "dest=C:UserszsmallDesktopCustomTest"    
DIR /A:D /B %dest% > folders.txt    
for /f "delims=" %%G in (folders.txt) do (
C:WindowsSystem32robocopy.exe "%source%" "%dest%%%G" /copy:DAT /E /W:2 /R:2 /MT:8
)
pause

What it does

  • lists all folders (no subfolders) from your destination folder and writes the names to a text file
  • loops through every folder in that list file
  • executes a robocopy command with the current folder as destination
    (source is always the same folder)
  • robocopy copies all folders, subfolders and files including data, attributes and timestamps

For information about the used parameters, look here:

Don’t try to do it without saving the list first in a textfile. Or you may end up like me, who was creating thousands of subfolders with the same name.