View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default Loop thru folders

I put together this code that deletes error log files (those with no
extension FileType: "File").

Sub NoExtFiles()
fPath = Range("Path").Value
Set fso = CreateObject _
("Scripting.FileSystemObject")
Set folder = fso.GetFolder(fPath)

For Each file In folder.Files
If fso.GetExtensionName(file) = "" Then
Debug.Print file.Name
file.Delete
End If
Next
Set folder = Nothing
Set fso = Nothing
End Sub

It works well for a fixed path; however I want to loop through each folder
in the path (defined in the range "Path") and delete all files explained
above.

Can anyone help?

Thanks in advance,

Sam