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

17.8k views Asked by At

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.

1

There are 1 answers

4
Shan Khan On BEST ANSWER

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