我想使用VB脚本删除超过60天的文件和文件夹。
如何在脚本中排除特定文件夹?
' Global FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Start at the root
DoFolder "H:\Werk\Testfolder"
' Recursive function
Sub DoFolder(strFolder)
With objFSO.GetFolder(strFolder)
For Each objFile In .Files
If objFile.DateCreated < Date - 60 Then objFile.Delete
Next
For Each objFolder In .SubFolders
DoFolder objFolder.Path
Next
' Checked every file and subfolder. If this folder is empty, remove it...
If .Files.Count = 0 Then If .SubFolders.Count = 0 Then .Delete
End With
End Sub
我想排除以下内容:
H:\ Werk \ Testfolder \ Favorieten
和
的 H:\ WERK \ Testfolder \ OneNote的-notitieblokken
我该怎么做?
答案 0 :(得分:0)
For Each objFolder In .SubFolders
If objfolder.path <> "c:\whatever\whatever.ext" then
DoFolder objFolder.Path
End If
Next
你是怎么做的。