If you use the robocopy /s
command without the /e
switch, then it won't copy any empty folders. It appears that you are using robocopy /s /e
since you are having problems with empty top-level folders. If you don't want any empty sub-folders either, then just omit the /e
switch and no empty folders will be created in the destination. If you need to copy the empty sub-folders, then you can't avoid also copying the empty top-level folders. However, you could easily remove the empty top level folders like this:
robocopy C:\Source\Dir X:\Dest\Dir /s /e
cd /d X:\Dest\Dir
for /d %%i in (*.*) do rd "%%i" > nul 2>&1
The cd
command changes to the destination drive & folder and then the for
command tries to remove all top-level folders. Only the ones that are empty will be removed. The > nul 2>&1
hides the output and errors since folders that aren't empty will show an error message, which can just be ignored.