windows中日期自动替换
环境:windows、cmd
要求:一个配置文件中有日期,程序执行一次日期自动加一天。
链接: https://pan.baidu.com/s/1SJir4jMfJCdQmLkdkqdI5Q 提取码: di2n
文件三个:
param.properties 参数文件需要修改其中日期
delete.bat 执行脚本,执行一次日期自动加一天
0systemupdate.vbs vbs脚本,调用delete脚本,多次执行(只用双击该文件完成功能)
下面是脚本内容:
param.properties
rmDir=/5101/20201232,/5103/20201232,/5104/20201232,/5105/20201232
-------------------------
delete.bat
@echo off
chcp 65001
@echo off
:: 找到文件,找到日期, 替换日期,月底需要修改parame到月初时间
setlocal enabledelayedexpansion
set file=.\param.properties
for %%i in ("%file%") do set file=%%~fi
echo.
for /f "delims=/, tokens=1,3" %%i in (.\param.properties) do set replaced=%%j
echo befor:%replaced%
echo.
set all=
set num2=1
set /a all = !replaced!+!num2!
echo after:%all%
for /f "delims=" %%i in ('type "%file%"') do (
set str=%%i
set "str=!str:%replaced%=%all%!"
echo !str!>>"%file%"_tmp.txt
)
move "%file%"_tmp.txt "%file%"
exit
---------------------------
0systemupdate.vbs
set wshshell=createobject("wscript.shell")
wshshell.run "delete.bat",1,true
wshshell.run "delete.bat",1,true
MsgBox "提示语",title,"完成提示"
做一个决定,并不难,难的是付诸行动,并且坚持到底。

浙公网安备 33010602011771号