用vbs实现搜索目标文件夹(包括子文件夹)下的某个类型的文件,并复制到d:dd盘下

用vbs实现搜索目标文件夹(包括子文件夹)下的某个类型的文件,并复制到d:dd盘下,第1张

Tpath="D:\dd"

path="D:\123"首雹碧 ' 要搜索的文肆袜件夹

Set fso=CreateObject("scripting.filesystemobject")

scan path,Tpath

For Each sfolder In fso.GetFolder(path).SubFolders

scan sfolder,Tpath

Next

Sub scan(folder,Tpath)

For Each file In fso.GetFolder(folder).Files

exr=fso.GetExtensionName(file.Path)

If exr="xml" Then

If Right(file.Name,6)="aa.xml" Then

If fso.FileExists(Tpath&"\"&file.Name) Then

a=MsgBox("文件 "&file.Name&" 已存在,是否覆盖?"&vbCrLf&vbCrLf&"源:"&file.Path,vbInformation+vbOKCancel,"警告")

If a=1 Then

file.Copy Tpath&"\者举",True

End If

Else

file.Copy Tpath&"\"

End If

End If

End If

Next

End Sub

set r=createobject("scripting.filesystemobject"唯搭拿)

p="c:\a.rar"'指搭目标

w="tem1.rar"'源枝纳

pth="d:\123\a34"'源文件夹

f pth

d pth

sub d(x)

on error resume next

for each i in r.getfolder(x).subfolders

f i

d i

next

end sub

sub f(n)

for each c in r.getfolder(n).files

if instr(1,c,w,1)>0 then

r.copyfile c,p

if r.fileexists(c) then

msgbox"成功",64

else

msgbox"失败",16

end if

wscript.quit

end if

next

end sub


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/tougao/12377726.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-23
下一篇2023-05-23

发表评论

登录后才能评论

评论列表(0条)

    保存