简体   繁体   English

如何在命令行中使用 Robocopy 复制带有时间戳的文件

[英]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\\ 时的“K:\\Builds”

     F:\\Builds\\ ---> F:\\Builds_26092015
  2. "E:\\" when copied to "K:\\Shan Khan\\Workspace"复制到“K:\\Shan Khan\\Workspace”时的“E:\\”

     "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.请注意, K 盘受密码保护,我在将 IP 地址映射到 K 盘时手动保存了密码。

I tried this lines and it works.我试过这条线,它的工作原理。 it created the directory in such a way Fri 06_26_2015它以这种方式创建了目录 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM