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

谁说胖子不能爱 提交于 2021-02-08 03:43:16

问题


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:


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


来源:https://stackoverflow.com/questions/31064976/how-to-use-robocopy-to-copy-files-with-timestamp-in-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!