我需要帮助一个每隔6个小时运行一次Windows任务计划程序的批处理文件,我希望每次运行任务时,都要更改一条看起来像这样的行:
hostname =“Sometextandnumbers [GMT + 4] Sometextandnumbers”;
我想在每次任务运行时增加6小时GMT + 4,直到它回到GMT + 4(GMT + 4到GMT + 10到GMT-4到GMT-10到GMT + 4) 。问题是,我不知道如何在Windows cmd或任何其他程序中这样做。 我安装了Notepad ++,所以如果有任何方法可以利用CMD,它可以工作。 提前致谢!此致,汤姆。
答案 0 :(得分:0)
@echo off
setlocal EnableDelayedExpansion
rem Save replacement strings
set i=0
:nextParam
if "%~1" equ "" goto endParams
set /A i+=1
set "replace[!i!]=%~1"
shift
goto nextParam
:endParams
rem Process the file
(for /F "delims=" %%a in (input.txt) do (
set "line=%%a"
for /L %%i in (1,1,%i%) do (
for /F "delims=" %%r in ("!replace[%%i]!") do (
set "line=!line:%%r!"
)
)
echo !line!
)) > output.txt
要使用此程序,请将引号括起来的替换字符串作为参数。例如:
"Sometextandnumbers [GMT+4] Sometextandnumbers=Sometextandnumbers [GMT+10] Sometextandnumbers"
感谢Aacini