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?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
You’ve most likely forgotten the
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