I'm trying to use xcopy to copy over several files and directories onto an external hard drive. The following command works fine...
xcopy d:\location\folder /e
... except it's not copying over any files/directories withing d:/location/folder that have spaces. I understand that Windows requires file names with spaces need to be enclosed in quotes, but what do I do if I'm trying to do a huge recursive copy where there may be several files or folders with spaces in the name?
To append files, specify a single file for destination, but multiple files for source (that is, by using wildcards or file1+file2+file3 format). If you omit destination, the xcopy command copies the files to the current directory.
To do so, run the Xcopy command with /T switch. Using the /T switch will cause Xcopy to copy only the directory tree structure to the destination but ignores the empty directories. You can also add the /E switch to the command to include empty directories, as shown in the example command below.
MS-DOS and Windows command line By default, the basic xcopy command only copies files in the directory you specify as the source directory. You must use the /E option to copy subdirectories in the source directory as well.
Use quotes:
xcopy "d:\location\folder" /e
You should use quotes the following way:
xcopy "d:location\folder\anotherfolder\folder with spaces"
Note the unit letter and the colon go outside the quotes and no \
at the beginning either.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With