
Smart Delete Files And Smart Delete Folders Routines?
Public Sub DeleteOfFiles(ByVal thePath As String, ByVal theMatch As
String)
Dim theFileSystem As FileSystemObject, _
theFolder As Folder, _
theFile As Scripting.File, _
theSubFolder As Folder
'
theFileSystem = New FileSystemObject
With theFileSystem
'
theFolder = .GetFolder _
(thePath)
For Each theFile In theFolder.Files
'
theFile. _
Delete(True)
Next
'
For Each theSubFolder In theFolder.SubFolders
'
Call DeleteOfFiles _
(theSubFolder.Path, theMatch)
Next
End With
End Sub
The above routine would delete all files... but what I need is to
delete only the files, or subfolders, that match a given
specification. In either case all matches are deleted in refence to
files or folders based on the match pattern.
For example... D:\_FOLDER\-*.* would delete all files that start with
'-' symbol, and all files in all subfolders that start with '-'.
Another example... D:\_FOLDER\-*. would delete all subfolders that
start with '-' symbol.
Can anyone help with this?