我的代码搜索文件夹和子文件夹。处理这些文件夹中的每个文件时,我希望能够排除打开的文件或系统文件。任何帮助都会很棒!
Dim fso, oFolder, oSubfolder, oFile, queue As Collection
Set fso = CreateObject("Scripting.FileSystemObject")
Set queue = New Collection
queue.Add fso.GetFolder("folderpath")
Do While queue.Count > 0
Set oFolder = queue(1)
queue.Remove 1 'dequeue
For Each oSubfolder In oFolder.SubFolders
If UCase(oSubfolder.Name) <> "DO NOT USE" Then
queue.Add oSubfolder 'enqueue
Else
End If
Next oSubfolder
For Each oFile In oFolder.Files
'Process each file but exclude files such as "~xxxxxx" or thumbs.db or xxxx.tmp files
Next oFile
Loop