2013-05-11 20 views
-1

我需要一些批處理文件的幫助,這個批處理文件每6小時運行一次,並且每次運行任務時都需要它,幾乎看起來像這樣:Windows cmd/batch - 編輯.cfg文件where text = something

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
@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

相關問題