Search code examples
batch-filexcopy

understanding xcopy command


I am modifying a batch script to move a directory from one place to another. In the batch code, there are these two lines. I don't understand the first parts

echo xcopy %SOURCE_FILE% %TARGET_FILE% /Y /Z /C /F 1>>"%logfile%" 2>&1

echo F|xcopy %SOURCE_FILE% %TARGET_FILE% /Y /Z /C /F 1>>"%logfile%" 2>&1

  1. Do these lines of code execute the copy or just write out to the log file? I ask this because the code currently copies, however, there is no line of xcopy without the echo in front.
  2. In line two what does F|xcopy mean?
  3. Other then the F|xcopy on the second line, what is the difference between the two?

Solution

  • The first writes the command it is about to execute to a log file, but does nothing useful.

    The second actually executes XCOPY but answers the question that gets asked with the letter "F" presumably when XCOPY asks "Do you mean Files or Directories?"