@echo off FOR /F "tokens=1-3 delims=/ " %%a IN ("%date%") DO (SET _today=%%a-%%b-%%c) FOR /F "tokens=1-3 delims=/ " %%a IN ("%date%") DO (SET _year=%%a) XCOPY D:\WebSite\*.xml D:\Backup\%_year%\%_today% /D/K/Y/C/I/H/S XCOPY D:\WebSite\*.ini D:\Backup\%_year%\%_today% /D/K/Y/C/I/H/S XCOPY D:\WebSite\*.config D:\Backup\%_year%\%_today% /D/K/Y/C/I/H/S echo "已將所有Web.config檔案複製至"D:\Opbackup\%_year%\%_today%"目錄下 pause
此為範例 可自行修改備份的檔案及目錄 另存為xxx.bat執行即可