Robocopy script with time-date based logfile names

Feed: Scriptorlog
Posted on: Tuesday, September 30, 2008 4:45 PM
Author: iRobx
Subject: Robocopy script with time-date based logfile names

This is a trivial robocopy batch that I chose to post simply to illustrate the technique of creating unique logfile names based on date and time using the set command’s search and replace function along with the build in %date% and %time% environment variables.

set tdate=%date: =%
set tdate=%tdate:/=%
set ttime=%time::=%
set ttime=%ttime:.=%
set ttime=%ttime: =%
robocopy /w:0 /r:0 \\servername\d$\share d:\share /e /np /mir >> c:\logs\%tdate%-%ttime%.log
robocopy /w:0 /r:0 \\servername\d$\apps d:\apps /e /np /mir >> c:\logs\%tdate%-%ttime%.log
Advertisements
This entry was posted in NT Shell Scripts. Bookmark the permalink.

3 Responses to Robocopy script with time-date based logfile names

  1. Dave says:

    Thanks! I am using robocopy to backup daily. The appended log was a mile long. This is exactly what I was looking for!

  2. hidde2015 says:

    Little late to the party, but this worked for me :)
    Thanks!

    -Hidde RRBSecurity

  3. Luke G says:

    Many thanks to iRobx! I am doing a file-server-migration in our Datacenter using Robocopy with your script. Works great!
    Best from Colgne, Germany
    Luke G.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s