Experts Exchange connects you with the people and services you need so you can get back to work.
The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!
' Define the folder to scan, and the age of files to locate
strBaseDir = "D:\Client FTP Folders"
datBefore = CDate("11/03/2013 7:32:24 PM")
intLevels = 2
' Create a dictionary to hold the list of extensions to list
Set dicExt = CreateObject("Scripting.Dictionary")
dicExt.CompareMode = vbTextCompare
dicExt.Add "ord", 0
' Set up filesystem object for usage
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Look for files
FindFiles objFSO.GetFolder(strBaseDir), 0
' Subroutine (recursive) to search for files to delete
Sub FindFiles(objFolder, ByVal intLevel)
On Error Resume Next
intLevel = intLevel + 1
If intLevel <= intLevels Then
' Look at all files in this folder
For Each objFile In objFolder.Files
' Make sure it's one of the extensions we want to delete
If dicExt.Exists(objFSO.GetExtensionName(objFile.Path)) Then
' See if it's old enough to display
If objFile.DateCreated < datBefore Then
WScript.StdOut.WriteLine objFile.Path & ", " & objFile.DateCreated
' See if we were able to access this folder, if not don't recurse into it
If Err.Number = 0 Then
' Recursively drill down into subfolder
For Each objSubFolder In objFolder.SubFolders
FindFiles objSubFolder, intLevel
Open in new window
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim path As String = "C:\\temp"
Dim topdir As New IO.DirectoryInfo(path)
Dim dirList As New List(Of DirectoryInfo)
For Each dir As DirectoryInfo In dirList
Sub findSubfoldersRecursively(ByVal dir As IO.DirectoryInfo, ByVal dirList As List(Of DirectoryInfo))
Dim dirs() As DirectoryInfo = dir.GetDirectories
For Each adir As DirectoryInfo In dirs
dirList.Add(adir) ' add to a list
findSubfoldersRecursively(adir, dirList) ' and check this subfolder for subfolders
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.
Premium members get this course for $259.00.
Premium members get this course for $159.20.
Premium members get this course for $151.20.
Premium members get this course for $62.50.
Premium members get this course for $108.00.