|
用正则去处理,但是挺奇怪的,测试\s能匹配上,但是替换无效果,太久没用正则都不会用了……
Sub 批量重命名含空格文件()
Dim MyPath, MyName, rege As Object, mh, ss, str$
Application.ScreenUpdating = False
MyPath = InputBox("请输入要重命名的文件路径", "HI", "c:\") & "\"
MyName = Dir(MyPath & "\*.*")
Set rege = CreateObject("vbscript.regexp")
If MyPath = "" Then Exit Sub
Do While MyName <> ""
With rege
.Global = True
.Pattern = "[一-龢]+|\..*"
Set mh = .Execute(MyName)
For Each ss In mh
str = str & ss
Next ss
MyName2 = str
str = ""
End With
Name MyPath & MyName As MyPath & MyName2
MyName = Dir()
Loop
End Sub
|
|