Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Log For xcopy batch file  (Read 72621 times)

0 Members and 1 Guest are viewing this topic.

iDK

  • Guest
Log For xcopy batch file
« on: November 13, 2008, 06:42:06 PM »
Hi All,

I want to have a log of the below batch script i wrote and can't seem to find a way to create it.

start /wait /b xcopy "z:\*.id" "c:\notes\data" /d /L /y >> "C:\Documents and Settings\Administrator\Desktop\ID_Log.txt"

echo. |time |find "current" >> log
echo. |date |find "current" >> log


I have managed to get the files that are copied into a log file, but i would like have the output of the batch file with a date stamp saved into a log file.

please keep in mind this is my first ever attempt to writing a batch script, i am open to any suggestions. Perhpas my approach is wrong or there is a better way of doing this.

Thanks in advance for any assistance or tips.

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Log For xcopy batch file
« Reply #1 on: November 14, 2008, 04:57:15 AM »
Using start /wait is only helpful when the started task runs in it's own window and there is a need for the batch file to wait. Otherwise, running commands in-line accomplishes the same thing without wasting resources or adding complexity.

Code: [Select]
xcopy "z:\*.id" "c:\notes\data" /d /L /y >> "C:\Documents and Settings\Administrator\Desktop\ID_Log.txt"

echo. |time |find "current" >> "C:\Documents and Settings\Administrator\Desktop\ID_Log.txt"
echo. |date |find "current" >> "C:\Documents and Settings\Administrator\Desktop\ID_Log.txt"

Note that the XCOPY will append the log to any existing log. If you wish to create a new log each time you run your file, replace >> with > on the XCOPY line.

Good luck.  8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein