@ECHO OFF
SET backdir=backup
SET snapshotdir=snapshots
SET worldprefix=world_
SET itdate=%date:~10,4%-%date:~4,2%-%date:~7,2%
SET hour=%time:~0,2%
IF "%hour:~0,1%" == " " SET hour=0%hour:~1,1%
echo Current date: %itdate%. Current hour: %hour%. Current Minute:Second: %time:~3,2%:%time:~6,2%
forfiles /m "%worldprefix%*" /c (
echo Copying World: @path
cmd /c xcopy /e /c /h /i /v /r /y /q @file %snapshotdir%\@file\%itdate%-%hour%-%time:~3,2%-%time:~6,2%
cmd /c xcopy /e /c /h /i /v /r /y /q @file %backdir%\%itdate%D\worlds\@file
)
echo Copying Plugins
xcopy /e /c /h /i /v /r /y /q plugins %backdir%\%itdate%D\plugins\
xcopy /e /c /h /i /v /r /y /q %backdir%\%itdate%D %backdir%\%itdate%-%hour%H\
echo Backup Complete (assuming no errors above). Attempting to remove old files..
forfiles /p "%snapshotdir%" /c "cmd /c rmdir /s /q @path" /d -7
forfiles /p "%backdir%" /m "*H" /c "cmd /c rmdir /s /q @path" /d -2
forfiles /p "%backdir%" /m "*D" /c "cmd /c rmdir /s /q @path" /d -14
PAUSE
我正在尝试复制所有以“world_”为前缀的文件。当我尝试在循环中使用多个命令时遇到问题。我试图编写上面想要的批处理脚本。