I'm trying to use xcopy /exclude:exclude.txt
and one of the paths in exclude.txt
has a space in it and it's not working. Is there any workaround for this?
Windows – can’t exclude path with a space (xcopy)
command linewindowsxcopy
command linewindowsxcopy
I'm trying to use xcopy /exclude:exclude.txt
and one of the paths in exclude.txt
has a space in it and it's not working. Is there any workaround for this?
Best Answer
Reading through the relevant sections of the xcopy help
We can see that the exclude option is not working on paths or file names but "filters". To illustrate this I'll try to give a short example. Picture this exclude.txt
This will filter out any file that has unicorns or dolphins anywhere in its name. e.g Dolphins.txt will be filtered but Ponys.txt will be fine.
To get back to your issue. The reason that your filter isn't matching isn't because of the space in the path. By default xcopy will only care about the filename and not the full path, any filter you have that includes a full path will not match and the file will get copied.
You can change this behavior of xcopy by supplying the /f flag in your command. This should solve the issue you're seeing.