Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does xcopy not copy files when using these parameters?

Tags:

windows

cmd

xcopy

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.

like image 511
Saggio Avatar asked Mar 03 '11 16:03

Saggio


1 Answers

xcopy will also report 0 File(s) copied if you use forward slashes "/" in paths instead of backslashes "\", though ONLY if you've enclosed the path in quotes.

  1. This fails with "0 File(s) copied"

    xcopy "pathname1/file" pathname2\file
    
  2. This fails with "Invalid number of parameters"

    xcopy pathname1/file pathname2\file
    
  3. This works just fine

    xcopy pathname1\file pathname2\file
    
like image 193
iandallas Avatar answered Sep 21 '22 22:09

iandallas