考虑批处理不能正确处理特殊字符,再给出vbs方案:- Dim vbstr, fso, file, folder, choice, str, rpstr
- Do Until choice = 1 Or choice =2
- choice = InputBox("请选择模式:1.固定替换 2.随机替换")
- Loop
- If choice = 1 Then
- str = "游戏"
- Else
- str = "1234567"
- End If
- Set fso = CreateObject("scripting.filesystemobject")
- Set ws = CreateObject("wscript.shell")
- For Each folder In Split(fso.OpenTextFile("a.txt", 1).ReadAll(), vbCrLf)
- If choice = 1 Then
- folder = Split(folder, "@")(0)
- rpstr = Split(folder, "@")(1)
- Else
- Randomize
- rpstr = Int((Rnd*90)) + 10 '随机数自己改
- End If
- For Each file In fso.GetFolder(ws.CurrentDirectory & "\" & folder).Files
- If LCase(fso.GetExtensionName(file)) = "php" Then
- vbstr = Replace(fso.OpenTextFile(file, 1).ReadAll(), str, rpstr)
- fso.OpenTextFile(file, 2, 1).Write vbstr
- End If
- Next
- Next
- Set ws = Nothing
- Set fso = Nothing
复制代码
|