代码如下:
@echo off
for /f "tokens=2 delims==" %%a in ('wmic os get localdatetime /value') do (set ct=%%a)
set date=%ct:~0,8%
set h=%ct:~8,2%
set m=%ct:~10,2%
rem 设置源文件路径和目标文件夹路径
set srcSource=E:\Program Files\TheWorld 2.0\TheWorld.ini
set srcDist=E:\Program Files\TheWorld 2.0\TW_backup
rem 将源文件拷贝到目标文件夹并按照日期格式重命名
copy "%srcSource%" "%srcDist%"
ren "%srcDist%"\TheWorld.ini %date%-%h%%m%-TheWorld.ini
pause