We help IT Professionals succeed at work.

xcopy command

IP4IT Staff
IP4IT Staff asked
on
hi all
i am doing an xcopy of a large file over the net
i want to see the start time and the finnish time in a .txt document on the C:\
i am using the following command  

echo time > C:\Start-backup-time-report.txt
xcopy /S /Y /F Y:\ C:\
echo time > C:\end-backup-time-report.txt

when i open the text file all it has is "time"

what am i doing worng and how do i fix it

thanks in advance for helping
robbie
Comment
Watch Question

Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
Try this:

ECHO %TIME% > filename.txt

if you want the date too then use:

ECHO %DATE% %TIME% > filename.txt

Hope this helps,
~bp
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
These can be seen at the bottom of a FOR /? display, which shows the following:

If Command Extensions are enabled, then there are several dynamic
environment variables that can be expanded but which don't show up in
the list of variables displayed by SET.  These variable values are
computed dynamically each time the value of the variable is expanded.
If the user explicitly defines a variable with one of these names, then
that definition will override the dynamic one described below:

%CD% - expands to the current directory string.

%DATE% - expands to current date using same format as DATE command.

%TIME% - expands to current time using same format as TIME command.

%RANDOM% - expands to a random decimal number between 0 and 32767.

%ERRORLEVEL% - expands to the current ERRORLEVEL value

%CMDEXTVERSION% - expands to the current Command Processor Extensions
    version number.

%CMDCMDLINE% - expands to the original command line that invoked the
    Command Processor.

~bp
Test your restores, not your backups...
Top Expert 2016
Commented:
An equivalent way to accomplish this would be running the TIME command with the /T option and piping it's output to a file, like:

TIME /T > filename.txt

but using this approach limits adding other text on the same output line, where as ECHO with %TIME% gives you that flexibility.

You might also consider something like this, and sending the start and stop times to the same files if you are just looking for sort of a log approach, might be easier to read.

echo XCOPY START = %TIME% >> C:\backup-time-report.txt
xcopy /S /Y /F Y:\ C:\
echo XCOPY ENDED = %TIME% >> C:\backup-time-report.txt

This may or may not be useful but thought I would mention it.

~bp

Author

Commented:
billprew

Author

Commented:
thanks billprew
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
Glad that helped, you're very welcome.

~bp