-1

I want to duplicate one folder with its subfolders in the same directory using the command prompt. But I am stuck as I cannot find a way to rename the duplicate folder.

I have tried

xcopy "TEMPLATE FOLDER" [destination]

I have also tried

copy "TEMPLATE FOLDER" [destination]

In my case the [destination] is the same folder where the "TEMPLATE FOLDER" is. I would like have the following directory

D:\dir1\dir2\dir3
11/28/2018  08:50 AM    <DIR>          .
11/28/2018  08:50 AM    <DIR>          ..
11/23/2018  08:31 AM    <DIR>          TEMPLATE FOLDER

As such:

D:\dir1\dir2\dir3
11/28/2018  08:50 AM    <DIR>          .
11/28/2018  08:50 AM    <DIR>          ..
11/23/2018  08:31 AM    <DIR>          TEMPLATE FOLDER
11/23/2018  08:31 AM    <DIR>          TEMPLATE FOLDER2

Thanks in advance

1

Try

xcopy /i "TEMPLATE FOLDER" "TEMPLATE FOLDER2"
  • Hi Scott, I tried as you said but it did not work – Epilotus Nov 28 '18 at 2:41
  • @Epilotus So what was the error message? What was the result of running the command? – DavidPostill Nov 28 '18 at 8:18
  • @Epilotus You need xcopy /i "TEMPLATE FOLDER"\* "TEMPLATE FOLDER2" if the source folder contains subdirectories. – DavidPostill Nov 28 '18 at 8:21
  • Hi @DavidPostill, thanks for the help. I tried the sintax and it shows 0 file(s) copied. Indeed the directory contains subdirectories – Epilotus Nov 28 '18 at 8:47
0

I researched further and found a way to duplicate my folder. Here is how I did it:

xcopy /E "TEMPLATE FOLDER" "TEMPLATE FOLDER2"

So there is no need to add a destination as it will automatically use the directory that I am in. And combined with the /E flag, it copies the empty subfolders (this seems to be a requirement).

Thanks for the help @DavidPostill and @Scott

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.