Vbscript list all PDF files in folder and subfolders -
well here code can not filter listing using objfile.extension sure thing silly
set objfso = createobject("scripting.filesystemobject") objstartfolder = "c:\dev" set objfolder = objfso.getfolder(objstartfolder) wscript.echo objfolder.path set colfiles = objfolder.files each objfile in colfiles if objfile.extension = "pdf" wscript.echo objfile.name end if next wscript.echo showsubfolders objfso.getfolder(objstartfolder) sub showsubfolders(folder) each subfolder in folder.subfolders wscript.echo subfolder.path set objfolder = objfso.getfolder(subfolder.path) set colfiles = objfolder.files each objfile in colfiles wscript.echo objfile.name next wscript.echo showsubfolders subfolder next end sub
on run comes error
(11, 1) microsoft vbscript runtime error: object doesn't support property or method: 'objfile.extension'
you'll want use getextensionname method on filesystemobject object.
set x = createobject("scripting.filesystemobject") wscript.echo x.getextensionname("foo.pdf")
in example, try using this
for each objfile in colfiles if ucase(objfso.getextensionname(objfile.name)) = "pdf" wscript.echo objfile.name end if next
Comments
Post a Comment