BAT 一键复制文件
1.代码如下
SET NowDate=%date:~10,4%%date:~4,2%%date:~7,2% REM SET NowDate=%date:~3,4%%date:~8,2%%date:~11,2% SET NowTime=%time:~0,2%%time:~3,2%%time:~6,2% SET DirToBackup=%NowDate%\V-%NowDate%-%NowTime% REM ECHO %Dir% MKDIR %DirToBackup% xcopy /I /E /K /V /Y /EXCLUDE:xcopy-excluding.txt C:\Working\Projects\publishs\IIS %DirToBackup% PAUSE
可以使用命令获得相对路径
REM 当前路径为:C:\Working\Projects\publishs\IIS cd .. xcopy /I /E /K /V /Y %cd%\IIS\* %cd%\Releases\%DirToBackup%
1.1.C:\Working\Projects\publishs\IIS: 需要备份文件夹的路径
1.2.xcopy-excluding.txt: 不需要复制文件名单
2.xcopy-excluding.txt
\Outputs\
\Web.config
Reference:
https://docs.microsoft.com/zh-cn/windows-server/administration/windows-commands/xcopy