Well here is my code but I just can not filter the listing using the objFile.Extension i am sure it is some thing silly
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "C:\dev"
Set objFolder = objFSO.GetFolder(objStartFolder)
Wscript.Echo objFolder.Path
Set colFiles = objFolder.Files
For Each objFile in colFiles
If objFile.Extension = "PDF" Then
Wscript.Echo objFile.Name
End If
Next
Wscript.Echo
ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
Wscript.Echo Subfolder.Path
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
Wscript.Echo objFile.Name
Next
Wscript.Echo
ShowSubFolders Subfolder
Next
End Sub
On run it comes back with the error
(11, 1) Microsoft VBScript runtime error: Object doesn't support this property or method: 'objFile.Extension'
The file extension may be case sentive...but the code works.
May not help OP, but hopefully others may find this helpful:
run
using shell object
StdOut will contain all PDF files
You'll want to use the GetExtensionName method on the FileSystemObject object.
In your example, try using this
Check this code :
(For those who stumble upon this from your search engine of choice)
This just recursively traces down the folder, so you don't need to duplicate your code twice. Also the OPs logic is needlessly complex.