I’m trying to do a quick and simple game backup script and it’s not working for me. Here’s what I have.
@echo off
:main
RD /S /Q "C:\Users\Citadel\Desktop\Minecraft_Backups"
mkdir "C:\Users\Citadel\Desktop\Minecraft_Backups\%date% - %time%"
XCOPY "C:\Users\Citadel\AppData\Roaming\.minecraft\saves" "C:\Users\Citadel\Desktop\Minecraft_Backups\%date% - %time%" /D /E /C /R /I /K /Y
echo %date% - %time% - Backup Complete >> log.txt
PING 1.1.1.1 -n 1 -w 900000 >NUL
goto main
Honestly the mkdir command was a shot in the dark, but nothing so far has worked so I tried it.
The problem is that
%date%and%time%contain special characters that can’t be used in directory names. Try this at the top of your script:Or if you prefer 24-hour time, change the second line to:
And then use
%mydate%_%mytime%in place of%date% %time%.Note that this may have regional issues, but if you confirm it working for your machine, for local backups it will always be fine.