我曾经为维护技术人员维护一个内部cmd线工具。 因此,我想确保我保留了以前版本的文件的档案,以防万一出现问题。
我想创build一个简单的batch file,每隔X天就可以作为计划任务运行,以便在networking共享上创build开发文件夹的副本。
这是我想出来的。 不是最优雅的,但它完成了工作。 我已经通过了一个匿名的脚本,但是将目录路径替换为适合您需要的路径并不难。
@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"