Vbscript list all PDF files in folder and subfolders

前端 未结 7 1640
甜味超标
甜味超标 2020-12-03 14:18

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         


        
7条回答
  •  既然无缘
    2020-12-03 14:55

    (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.

    Wscript.Echo "begin."
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objSuperFolder = objFSO.GetFolder(WScript.Arguments(0))
    Call ShowSubfolders (objSuperFolder)
    
    Wscript.Echo "end."
    
    WScript.Quit 0
    
    Sub ShowSubFolders(fFolder)
        Set objFolder = objFSO.GetFolder(fFolder.Path)
        Set colFiles = objFolder.Files
        For Each objFile in colFiles
            If UCase(objFSO.GetExtensionName(objFile.name)) = "PDF" Then
                Wscript.Echo objFile.Name
            End If
        Next
    
        For Each Subfolder in fFolder.SubFolders
            ShowSubFolders(Subfolder)
        Next
    End Sub
    

提交回复
热议问题