'============================================
'code by lcx 修改网上原有的一个小程序,不知作者,那个程序没有对目录实现递归查找
'将本程序放在你要查找的目录下,或把查找的目录拖到此脚本上,估计还有bug
'=======================================================================================
On Error Resume next
Do Until False
Findstr=InputBox("请输入你要查找的字符(串):", "请输入")
If Findstr <> "" Then
Exit do
End If
Loop
repwith=InputBox("请输入你要替换的字符(串):,如果留空则只为查找", "请输入")
If Wscript.Arguments.Count <> 0 Then
For i=0 To WScript.Arguments.Count-1
folderpath=WScript.Arguments(i)
find(folderpath)
Next
Else
'处理当前目录
Set objShell = CreateObject("WScript.Shell")
folderpath=objShell.CurrentDirectory
find(folderpath)
End If
'替换主程序
Sub find(path)
set fso=CreateObject("Scripting.FileSystemObject")
set current=fso.GetFolder(path)
For Each file In current.Files
set fsofile=fso.OpenTextFile(file, 1, true)
On Error Resume next
tempstr=fsofile.Readall
If InstrRev(tempstr,Findstr, -1, 0)<>0 And repwith = "" Then
with Fso.opentextfile(left(Wscript.ScriptFullName,len(Wscript.ScriptFullName)-len(Wscript.ScriptName))&"\re.txt",8,true)
.writeline file
.close
end with
End If
If repwith <> "" Then
tempstr=replace(tempstr, Findstr, repwith)
set fsofile1=fso.OpenTextFile(file, 2, true)
fsofile1.WriteLine tempstr
fsofile.close
End if
Next
for each folder in current.subfolders
Call find(folder.path)
next
set fso=nothing
End Sub
msgbox "OK,查找的文件名保存在re.txt"
'code by lcx 修改网上原有的一个小程序,不知作者,那个程序没有对目录实现递归查找
'将本程序放在你要查找的目录下,或把查找的目录拖到此脚本上,估计还有bug
'=======================================================================================
On Error Resume next
Do Until False
Findstr=InputBox("请输入你要查找的字符(串):", "请输入")
If Findstr <> "" Then
Exit do
End If
Loop
repwith=InputBox("请输入你要替换的字符(串):,如果留空则只为查找", "请输入")
If Wscript.Arguments.Count <> 0 Then
For i=0 To WScript.Arguments.Count-1
folderpath=WScript.Arguments(i)
find(folderpath)
Next
Else
'处理当前目录
Set objShell = CreateObject("WScript.Shell")
folderpath=objShell.CurrentDirectory
find(folderpath)
End If
'替换主程序
Sub find(path)
set fso=CreateObject("Scripting.FileSystemObject")
set current=fso.GetFolder(path)
For Each file In current.Files
set fsofile=fso.OpenTextFile(file, 1, true)
On Error Resume next
tempstr=fsofile.Readall
If InstrRev(tempstr,Findstr, -1, 0)<>0 And repwith = "" Then
with Fso.opentextfile(left(Wscript.ScriptFullName,len(Wscript.ScriptFullName)-len(Wscript.ScriptName))&"\re.txt",8,true)
.writeline file
.close
end with
End If
If repwith <> "" Then
tempstr=replace(tempstr, Findstr, repwith)
set fsofile1=fso.OpenTextFile(file, 2, true)
fsofile1.WriteLine tempstr
fsofile.close
End if
Next
for each folder in current.subfolders
Call find(folder.path)
next
set fso=nothing
End Sub
msgbox "OK,查找的文件名保存在re.txt"
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
暂无“批量文件查找替换功能的vbs脚本”评论...
更新动态
2024年05月13日
2024年05月13日
- 哥斯拉大战金刚2:帝国崛起 Godzilla x Kong: The New Empire
- 千织角色攻略心得分享,千织角色武器攻略
- 《原神》茸茸城堡大喵险第四关攻略
- 《原神》4.5那芙万配队攻略 那芙万输出手法与出装推荐
- 任天堂社长:Switch继任者的宣布可能会影响公司销量
- 金海心.-.[金海心].专辑.(APE+CUE)
- 破碎之地新手能力选择推荐 能力效果分析
- 星穹铁道梦境护照16收集位置 那是一个最好的时代贴纸收集位置大全
- 苏曼《佳人曲HQ》头版限量[低速原抓WAV+CUE]
- 《小猫咪大城市》Steam”好评如潮”!好评率高达95%
- 最终幻想14 x 最终幻想XI联动任务星歌异闻再临
- 星穹铁道梦境护照17收集位置 晨星与昏星贴纸收集位置大全
- 三国谋定天下品鉴会圆满落幕 公测定档掀起SLG手游新热潮
- 孙露《同名专辑HQ》头版限量编号[低速原抓WAV+CUE]
- 崩坏星穹铁道2.2他落下的羽毛怎么做 他落下的羽毛隐藏成就攻略