本帖最后由 copp_x 于 2012-3-10 18:23 编辑
之前写过一个脚本 vbs批量修改文件名的 现在拿出分享
原文见于:http://x0day.sinaapp.com/?post=28- 'author:DM_,date:2012-1-27
- 'blog :http://x0day.sinaapp.com
- Dim fso,folderPath,folders,SubFolders
- folderPath = "c:\temp" '这里是需要批量修改文件名的文件夹的位置
- Set fso = CreateObject("scripting.filesystemobject")
-
- fileName_change folderPath
-
- Sub fileName_change(folderPath)
- Set folders = fso.GetFolder(folderPath)
- Set subFolders = folders.SubFolders
- Set files = folders.Files
-
- For Each file In files
- fileName = file.Name
- change_name = InputBox (file.Path,,filename)
- If Not change_name = filename Then
- If fso.FileExists(change_name) Then
- file.Name = change_name
-
- MsgBox "已将"&filename&_
- " 修改为:"&change_name
- Else MsgBox "file exists!"
- End If
-
- End If
-
- Next
- For Each folder In SubFolders'递归搜索
- fileName_change(folder.Path)
- Next
- End Sub
复制代码 代码有些粗糙,未对使用过程中inputbox和msgbox返回值进行处理。见谅 |