Using xcopy to copy multiple files/directories, some of which have spaces

M Thomas picture M Thomas · Apr 12, 2011 · Viewed 67.5k times · Source

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?

Answer

Ken White picture Ken White · Apr 12, 2011

Use quotes:

xcopy "d:\location\folder" /e