I copied a directory using

xcopy /S DIR DIR2

However, instead of a new folder, I got the file DIR2 without any extension, even though it said 86 File(s) copied.

Help says that /S also copies subdirectories. Why doesn't it work?

1 Answer 1


You’ve most likely forgotten the /I switch.

If Source is a directory or contains wildcards and Destination does not exist, xcopy assumes Destination specifies a directory name and creates a new directory. Then, xcopy copies all specified files into the new directory. By default, xcopy prompts you to specify whether Destination is a file or a directory.

If the folder didn’t exist you should’ve been prompted if the destination is a file or directory.

You might also be interested in the /e switch instead of /s, which copies all folders, even if they are empty.

There are a large amount of other parameters for xcopy you can find by using a /?. Seldom do my xcopies ever use /s by itself.

More information here: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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