@echo off
cd c:\windows\system32
RD /s /q "C:\File Server Backup\"
XCOPY "C:\File Server\*.*" "C:\File Server Backup\" /e /i /h
fc "C:\File Server\*" "C:\File Server Backup\*" > nul
if errorlevel 2 goto fail1
if errorlevel 1 goto fail1
if errorlevel 0 goto okay1
goto next
:okay1
echo Backup to C: is completed on %date% %time% > "C:\backup report.txt"
goto next
:fail1
echo Backup to C: is not completed on %date% %time% > "C:\backup report.txt"
echo Therefore, backup to F: is cancelled! >> "C:\backup report.txt"
goto next
:end
RD /s /q "F:\File Server Backup\"
XCOPY "C:\File Server\*.*" "F:\File Server Backup\" /e /i /h
fc "C:\File Server\*" "F:\File Server Backup\*" > nul
if errorlevel 2 goto fail2
if errorlevel 1 goto fail2
if errorlevel 0 goto okay2
goto end
:okay2
echo Backup to F: is completed on %date% %time% >> "C:\backup report.txt"
goto end
:fail2
echo Backup to F: is not completed on %date% %time% >> "C:\backup report.txt"
goto end
:end
======================
@echo off
rem: 指向 system32,以執行 RD
cd c:\windows\system32
rem: 移除資料夾"C:\File Server Backup\"
RD /s /q "C:\File Server Backup\"
rem: 複制 "C:\File Server\" 內所有文件到 "C:\File Server Backup\"
XCOPY "C:\File Server\*.*" "C:\File Server Backup\" /e /i /h
fc "C:\File Server\*" "C:\File Server Backup\*" > nul
if errorlevel 2 goto fail1
if errorlevel 1 goto fail1
if errorlevel 0 goto okay1
goto next
:okay1
rem: 清除"C:\backup report.txt"內的資料並在第一行輸入 "echo" 和 ">" 之間的文字
echo Backup to C: is completed on %date% %time% > "C:\backup report.txt"
goto next
:fail1
echo Backup to C: is not completed on %date% %time% > "C:\backup report.txt"
rem: 在下一行輸入 "echo" 和 ">>" 之間的文字
echo Therefore, backup to F: is cancelled! >> "C:\backup report.txt"
goto next
:end
RD /s /q "F:\File Server Backup\"
XCOPY "C:\File Server\*.*" "F:\File Server Backup\" /e /i /h
fc "C:\File Server\*" "F:\File Server Backup\*" > nul
if errorlevel 2 goto fail2
if errorlevel 1 goto fail2
if errorlevel 0 goto okay2
goto end
:okay2
echo Backup to F: is completed on %date% %time% >> "C:\backup report.txt"
goto end
:fail2
echo Backup to F: is not completed on %date% %time% >> "C:\backup report.txt"
goto end
:end