windowscmdxcopy

Why does xcopy not copy files when using these parameters?


I have a simple xcopy script that I'm running from the command line that reads a CSV file of directories and file names. I've used a very similar script with no problems before. Here is the script:

Z:\HOME\>for /f "delims=, tokens=1,2,3,4" %i in (Z:\HOME\MissingImages.csv) do
echo f | xcopy "Y:\%j\%k\%l" "C:\Horizon\%j\%k\%l" >> Z:\HOME\MissingImagesLog.txt

However, it is not copying any of the files over Here is an entry from the log file:

Does C:\Horizon\K\00\6bef500f.IMG  specify a file name
or directory name on the target
(F = file, D = directory)? f
0 File(s) copied

It's finding the images because if I change the root directory to something else the script will just populate the log file with 0 File(s) copied for all entries, so the files are there and can be seen...

Also, the Z:\ drive is on a network and not local, but again I have used a very similar script across a network without problems (it just takes longer).

I've tried different options like /i, /s, etc. but I can't seem to get it to copy any files over.


Solution

  • Well, that's annoying; I found the issue. It looks like when I generated my CSV file, it put a space at the end of each line, so xcopy was looking for files that had a space after the extension.

    The thing that was throwing me off was that it was finding the files, but couldn't copy them, making me think it was a network or xcopy issue.

    I just ran a sed script to remove the EOL spaces and the xcopy script is now working as expected.