CODE: [Copy to clipboard]
@echo off
for /f "delims=: tokens=1,2" %%i in ('"findstr /n . 123.txt"') do set %%i=%%j & set col=%%i
for /f "delims=:" %%m in ('"findstr /n /c:"内容" 123.txt"') do set num=%%m
set /a var = num - 1
for /l %%n in (1,1,%var%) do echo %%%%n%% | findstr . >>tmp.txt
echo %%%num%:内容=新内容%% | findstr . >>tmp.txt
set /a var = var + 2
for /l %%e in (%var%,1,%col%) do echo %%%%e%% | findstr . >>tmp.txt
自己看着改改,原理就这些了。CODE: [Copy to clipboard]
if WScript.Arguments.Count <> 0 Then
myFile = Wscript.Arguments(0)
else
SET oFO = CreateObject("SAFRCFileDlg.FileOpen")
oFO.OpenFileOpenDlg
myFile = oFO.FileName
end if
strOld = InputBox("输入要被替换的文字:")
if Len(Trim(strOld)) = 0 then Wscript.Quit
strNew = InputBox("输入被替换后的文字:")
if Len(Trim(strNew)) = 0 then Wscript.Quit
with CreateObject("Scripting.FileSystemObject")
SET FILE = .OpenTextFile(myFile,1,true)
fStr = FILE.Readall
FILE.Close
fStr = Replace(fStr,strOld,strNew,1,1)
SET FILE = .OpenTextFile(myFile,2,true)
FILE.Write fStr
end with
保存为 修改ini文件.vbs ,然后把要修改的文件直接拖放到它上面,然后按照提示来就行了,如果直接双击会打开对话框让你选择要修改的文件。