Vbscript列出文件夹和子文件夹中的所有PDF文件 [英] Vbscript list all PDF files in folder and subfolders
本文介绍了Vbscript列出文件夹和子文件夹中的所有PDF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码,但是我无法使用objFile.Extension过滤列表,我敢肯定这很愚蠢
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运行时错误:对象不支持此功能 属性或方法:'objFile.Extension'
(11, 1) Microsoft VBScript runtime error: Object doesn't support this property or method: 'objFile.Extension'
推荐答案
查看全文