Private Sub FileChecking()
Dim CheckFolder$, TargetFolder$, KeyWord$, ic%
CheckFolder = "D:\T1\" '检查路径,依需设置
TargetFolder = "D:\T2\" '备份路径,依需设置
KeyWord = "2022" '关键词,依码老氏需设置
ic = 1
For Each f In CreateObject("scripting.FileSystemObject").GetFolder(CheckFolder).Files
If f.Name Like "*" &KeyWord &"*" Then
FileCopy CheckFolder &f.Name, TargetFolder &f.Name
ic = ic + 1
End If
Next
MsgBox ic &"个文件复制完成!"
End Sub
以上希望能帮上忙!
Sub copyFiles(Path As String, afterPath)'Path:原文件夹滑旦枝路径;afterPath:目标文件夹路径
Dim Spath As String
Set fs = CreateObject("Scripting.FileSystemObject")
Spath = Dir(Path, vbDirectory)
Do While Len(Spath)
If Spath <>"."迟掘 And Spath <>".." Then
fs.CopyFolder Path, afterPath
Spath = Dir()
End If
Loop
End Sub
———————信敏—————————
版权声明:本文为CSDN博主「前端小菜鸟007」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_41844140/article/details/103188537
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)