2

I'm trying to copy all subfolders with their content of a specific folder but I don't want to copy the files in the root folder. For example, if my folder look like:

- root
  - file.txt
  - sub1
    - another-file.txt
  - sub2
    - one-more.txt

I'd like to copy it to a new folder which will look as follows afterwards:

- target
  - sub1
    - another-file.txt
  - sub2
    - one-more.txt

Thanks!

  • This is not possible using a single `robocopy` execution. You will have to call it in a loop or use PowerShell, for example. – Lenniey Nov 08 '18 at 10:26

1 Answers1

1

In a script:

for /D %%i in (S:\SourceDirectory\*.*) DO (
    robocopy %%i D:\DestinationDirectory\%%~ni /MIR
)

If you don't want to use the /MIR switch, you may need to experiment.

Greg Askew
  • 34,339
  • 3
  • 52
  • 81