Shan Khan
Shan Khan

Reputation: 10319

How to use Robocopy to copy files with TimeStamp in command line

Following is my command to copy the files in my computer and from my computer to network.

ROBOCOPY "K:\Builds" F:\Builds\ /E /COPY:DAT
ROBOCOPY "E:\" "K:\Shan Khan\" /E /COPY:DAT

How i can make timestamp in destination folder only when copying the file for example

  1. "K:\Builds" when copied to F:\Builds\

        F:\Builds\ ---> F:\Builds_26092015
    
  2. "E:\" when copied to "K:\Shan Khan\Workspace"

      "K:\Shan Khan\Workspace"---> "K:\Shan Khan\Workspace_26092015"   
    

Kindly note that K drive is password protected and i manually saved the password while mapping the IP address to K drive.

Upvotes: 2

Views: 18954

Answers (1)

Shan Khan
Shan Khan

Reputation: 10319

I tried this lines and it works. it created the directory in such a way Fri 06_26_2015

for /f "tokens=1* delims=" %%a in ('date /T') do set datestr=%%a
md F:\Builds\"%date:/=_%"
ROBOCOPY "K:\Builds" "F:\Builds\%date:/=_%" /E /COPY:DAT /DCOPY:T

Upvotes: 1

Related Questions