Vbscript list all PDF files in folder and subfolders

前端 未结 7 1636
甜味超标
甜味超标 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 15:09

    The file extension may be case sentive...but the code works.

    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
      strFileName = objFile.Name
    
      If objFSO.GetExtensionName(strFileName) = "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
    
    0 讨论(0)
提交回复
热议问题