vbs“通配符”问题...
replace不支持通配符。可以使用正则表达式。
------------------------------------------
既然没有样本就将就用吧:
strFile = "1.txt"
oFile = "2.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFile, 1)
Do While not objFile.AtEndOfStream
strLine = objFile.ReadLine
If Instr(strLine,"1313") > 0 Then
strLine = Replace(strLine,"asdfa1313","2221313")
strLine = Replace(strLine,"45647561313","2221313")
strLine = Replace(strLine,"1u2j%1313","2221313")
Else
strLine = strLine
End If
colLines = colLines & strLine & vbCrLf
Loop
objFile.Close
Set objFile = objFSO.CreateTextFile(oFile, True)
objFile.Write colLines
objFile.Close
Set objFSO = Nothing
如何使用 BAT 或者 VBS 通配符替换 txt
@echo off & title 去除指定位置文字 By 依梦琴瑶setlocal enabledelayedexpansionfor /f "tokens=1-6 delims=_" %%a in ('dir /a-d/b *.txt') do ( set "Part4="&set "Part4=%%~d" ren "%%~a_%%~b_%%~c_%%~d_%%~e_%%~f" "%%~a_%%~b_%%~c!Part4:~1!_%%~e_%%~f")pause以上代码适合每列字符串长度不一定的情况,也就是说AB12345、A01和A002的字符串长度不确定。以下代码适合所有文件的前三列字符串长度都是一样的,也就是说包含下划线_在内,被删除字符前面的长度都是16位。@echo off & title 去除指定位置文字 By 依梦琴瑶setlocal enabledelayedexpansionfor %%a in (*.txt) do ( set "Str=%%~a" ren "%%~a" "!Str:~,16!!Str:~18!")pause

