![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-08-04 19:24 |
共 48,038 主题排行 / 350,123 发帖 / 今日 0 篇 / 48,251 会员排行 |
| DOS批处理 & 脚本技术(批处理室) » 给文件批量重命名 |
| 可打印版本 1,159 / 5 |
| 第1楼 wert123 | 发表于 2007-05-24 15:06 |
| 中级用户 发帖 135 积分 301 | |
|
给文件批量重命名 不知道是哪位高手写的code,以前保存在我的硬盘里,有些我看不懂,现在我把它贴出来 上面的代码是把'C:\Logs'文件夹下所以文件加-pl前缀 'C:\Logs'能用参数换出来吗,比如说弄个inputbox 以后方便些 还有哦,怎么把它该一下,给文件名的屁股后面加尾巴吗,哦,说错了 怎么把文件名字后面加-pl的后缀啊,怎么改 [ Last edited by wert123 on 2007-5-30 at 06:03 PM ] |
|
| 第2楼 slore | 发表于 2007-05-25 13:52 |
| 铂金会员 发帖 2,478 积分 5,212 | |
|
Dim objWMIService,colFileList
Dim TargetPath,ForeStr,MidStr,BackStr strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") TargetPath = InputBox("请输入要修改的目录路径:","路径","C:\Logs") Set colFileList = objWMIService.ExecQuery _ ("ASSOCIATORS OF {Win32_Directory.Name='" & TargetPath & "'} Where " _ & "ResultClass = CIM_DataFile") ForeStr = "pl-" '加在文件名之前的字符串 MidStr = "-Slore" '加在扩展名之前的字符串 BackStr = "-pl" '加在扩展名之后的字符串 For Each objFile In colFileList strNewName = objFile.Drive & objFile.Path & ForeStr & _ objFile.FileName & MidStr & "." & objFile.Extension & BackStr errResult = objFile.Rename(strNewName) Next Set colFileList = Nothing Set objWMIService = Nothing |
|
| 第3楼 wert123 | 发表于 2007-05-25 18:40 |
| 中级用户 发帖 135 积分 301 | |
|
谢谢啊
厉害啊,你和baomaboy的vbs都好厉害,还有什么话要说,还有多好少泪要流,我对你们死心塌地的五体投地了 [ Last edited by wert123 on 2007-5-25 at 06:42 PM ] |
|
| 第4楼 wert123 | 发表于 2007-05-25 18:46 |
| 中级用户 发帖 135 积分 301 | |
|
还有啊,能帮我把文件夹中(C:\Logs)的所有包含“qq”的文件名中,将qq的
前面和后面分别加上123吗,大家都一起回来再帮我看看吧 [ Last edited by wert123 on 2007-5-25 at 06:48 PM ] |
|
| 第5楼 slore | 发表于 2007-05-25 20:32 |
| 铂金会员 发帖 2,478 积分 5,212 | |
|
Dim objWMIService,colFileList
Dim TargetPath,ForeStr,MidStr,BackStr strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") TargetPath = InputBox("请输入要修改的目录路径:","路径","C:\Logs") Set colFileList = objWMIService.ExecQuery _ ("ASSOCIATORS OF {Win32_Directory.Name='" & TargetPath & "'} Where " _ & "ResultClass = CIM_DataFile") ForeStr = Empty ' "pl-" '加在文件名之前的字符串 MidStr = Empty '"-Slore" '加在扩展名之前的字符串 BackStr = Empty ' "-pl" '加在扩展名之后的字符串 For Each objFile In colFileList strNewName = objFile.Drive & objFile.Path & ForeStr & _ Replace(objFile.FileName,"qq","123qq123") & MidStr & "." & objFile.Extension & BackStr errResult = objFile.Rename(strNewName) Next Set colFileList = Nothing Set objWMIService = Nothing |
|
| 第6楼 wert123 | 发表于 2007-05-31 17:35 |
| 中级用户 发帖 135 积分 301 | |
|
谢谢啊
|
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |