这样?- Dir = "==NC=="
- Set fso = CreateObject("Scripting.FileSystemObject")
-
- For Each file in fso.GetFolder(Dir).Files
- Ext = fso.GetExtensionName(file)
- If Lcase(Ext) = "nc" or Lcase(Ext) = "txt" _
- or Lcase(Ext) = "ncd" or Lcase(Ext) = "pim" Then
- ReplaceStr fso.OpenTextFile(file,1).ReadAll
- End If
- Next
-
- Sub ReplaceStr(str)
- Set re = New RegExp
- re.Pattern = "==DK_T=="
- re.Global = True
- re.IgnoreCase = True
- If not re.Test(str) Then Exit Sub
- Do Until RegEx(a)
- a = InputBox("===输入G43T编号[1~999]===",file.Name,"1")
- If IsEmpty(a) Then Exit Sub
- Loop
- fso.OpenTextFile(file,2).Write re.Replace(str,"G43T" & a)
- End Sub
-
- Function RegEx(a)
- Set reg = New RegExp
- reg.Pattern = "^[1-9]\d{0,2}$"
- RegEx = reg.Test(a)
- End function
复制代码
|