|
- Sub zldccmx()
- Dim MyPath, MyName
- MyPath = "C:\Users\Administrator\Desktop\bo"
- MyName = Dir(MyPath & "\*.*")
- Do While MyName <> ""
- DoEvents
- x = InStr(MyName, "?")
- If x > 1 Then
- ChDir MyPath
- Shell "cmd.exe /k DIR " & MyPath & "" & Replace(MyName, "?", "*") & " /x >12324.txt" '调用DOS DIR 命令,获取文件的短文件名,8.3格式
- On Error Resume Next
- Close #1
- Open "12324.txt" For Input As #1
- Do While Not EOF(1)
- Line Input #1, textline
- If textline Like "*~*" & MyName Then
- y = Split(textline, " ")(15) '短文件名
- Close #2
- Open "re.bat" For Output As #2
- Print #2, "@echo off" & vbCrLf & "ren """ & MyPath & "" & y & """ """ & Replace(MyName, "?", "_") & """" & vbCrLf
- Close #2
- Shell "cmd.exe /c re.bat"
-
- End If
- Debug.Print textline
- Loop
- Close #1
-
- End If
- MyName = Dir()
- Loop
- Kill "re.bat"
- Kill "12324.txt"
- End Sub
复制代码 |
|