title: Command prompt logging with xcopy
body: <p>I have an xcopy script that I'm running that reads in a .csv file with directories and file names and parses it to copy the files.</p>
  
  <p>Here's the script:</p>
  
  <pre><code>echo F | for /f "delims=, tokens=1,2,3" %i in (D:\foo.csv) 
  do xcopy /i /d "Z:\%i\%j\%k" "Y:\%i\%j\%k" &gt;&gt; "D:\xcopy\Log.txt"
  </code></pre>
  
  <p>The output to the command prompt are the commands being executed:</p>
  
  <pre><code> echo F   | xcopy /i /d "Z:\hcri001\a1\
  ffce5a14-33ca-43cf-b366-af266c450979" "Y:\hcri001\a1\ffce5a14-33ca-43cf-b366
  -af266c450979"  1&gt;&gt;"D:\xopy\Log.txt
  </code></pre>
  
  <p>However, the log just has the output of the commands:</p>
  
  <pre><code>0 File(s) copied
  0 File(s) copied
  0 File(s) copied
  Does Y:\hcri001\2d\545392db-50fa-40d9-aaa2-0892ca5057f3 specify a file name
  or directory name on the target
  (F = file, D = directory)? F
  Z:\hcri001\2d\545392db-50fa-40d9-aaa2-0892ca5057f3
  1 File(s) copied
  </code></pre>
  
  <p>Is there someway to have both the commands being executed, as well as the output?
  Also, is there anyway to have some sort of counter that I can put in the beginning of the line? </p>
  
  <p>My Ideal log file would be in this format:</p>
  
  <pre><code>    1) C:\Desktop&gt;echo F   | xcopy /i /d "Z:\hcri001\a7\
      00a62a73-d7a7-4cfb-b55c-457bc67b3647" "Y:\hcri001\a7\00a62a73-d7a7-4cfb-b55c
      -457bc67b3647"  1&gt;&gt;"D:\Robocopy\AtlusPatient131172CopyLog.txt 
      0 File(s) copied
      2)    C:\Desktop&gt;echo F   | xcopy /i /d "Z:\hcri001\d5\
      003452354-d7a7-4cfb-452c-457bc67b3647" "Y:\hcri001\d5\003452354-d7a7-4cfb-452c-457bc67b3647"  1&gt;&gt;"D:\Robocopy\AtlusPatient131172CopyLog.txt 
      0 File(s) copied
      3)   C:\Desktop&gt;echo F   | xcopy /i /d "Z:\hcri001\2d\545392db-50fa-40d9-aaa2-0892ca5057f3" "Y:\hcri001\2d\545392db-50fa-40d9-aaa2-0892ca5057f3"  1&gt;&gt;"D:\Robocopy\AtlusPatient131172CopyLog.txt 
  Does Y:\hcri001\2d\545392db-50fa-40d9-aaa2-0892ca5057f3 specify a file name
          or directory name on the target
          (F = file, D = directory)? F
          Z:\hcri001\2d\545392db-50fa-40d9-aaa2-0892ca5057f3
          1 File(s) copied
  </code></pre>
  
  <p>and bonus points if the command can be trimmed to just include the file name instead of the whole command i.e. <code>1) "Z:\hcri001\2d\545392db-50fa-40d9-aaa2-0892ca5057f3"
                       0 File(s) copied</code></p>