The code attached is susposed to only delete empty directories created over x days old.
The code works ok if none of the files in a folder have special characters in their names (like ' or " or , ), but if a folder has file(s) with special characters it does not get counted in SubFolder.Files.Count
so the code winds up deleteing the folder even though there are files in the folder.
thank you in advance
Dim Days, Path
Set objFSO = CreateObject( "Scripting.FileSystemObject" )
path = "\\our-file\documents$\Quotes"
Days = 90
Set OrderPath = objFSO.GetFolder(path)
For Each Folder In OrderPath.subfolders
iNumberofFiles = 0
LastModDate = Folder.DateLastModified
Set SubFolderPath = objFSO.GetFolder(Folder)
For Each SubFolder In SubFolderPath.subfolders
iNumberOfFiles = iNumberOfFiles + SubFolder.Files.Count
If SubFolder.DateLastModified < LastModDate Then
LastModDate = SubFolder.DateLastModified
If DateDiff( "d", LastModDate, Date ) > Days and iNumberofFiles = 0 Then