我曾经为支持技术人员维护一个内部cmd线工具。因此,我想确保我保留了以前版本文件的存档,以防出现问题。
我想创建一个简单的批处理文件,我可以每隔X天作为计划任务运行,以在网络共享上制作开发文件夹的副本。
答案 0 :(得分:1)
这是我想出的。不是最优雅,但它完成了工作。我已经对脚本进行了匿名处理,但是根据您的需要更换目录路径并不困难。
@echo off
rem Copies the targeted directory to a folder in my documents and appends the date.
rem It also copies it to a backup dir on the shared drive itself
rem This part uses the current date a time, but arranges it into a useful manner
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
rem This copies the folder from the shared drive to a local copy in Documents.
robocopy "Z:\Support\Development" "C:\Users\SmithJ\Documents\Support_Tool\%mydate%" /LOG+:"C:\Users\SmithJ\Documents\Support_Tool\log.txt"
rem This copies the same shared folder to a backup folder on the share drive itself just to be sure.
robocopy "Z:\Support\Development" "Z:\SmithJ\Support_Tool_Backup\%mydate%" /LOG+:"Z:\SmithJ\Support_Tool_Backup\log.txt"