Open pdf files format with python -
i try open 100 pdf files python 2.7 code:
import arcpy,fnmatch,os rootpath = r"d:\desktop" pattern = '*.pdf' counter = 0 root, dirs, files in os.walk(rootpath): filename in fnmatch.filter(files, pattern): os.startfile(rootpath) counter = counter + 1 print counter
as result rootpath folder opened , python print number of pdf files:
>>> 39 >>>
no pdf files opened. search in forum , didn't find question answers request.
i don't know trying do, os.startfile
open adobe pdf reader (or other reader that's set default reader)... here how managed , seems working.
import os rootpath = "d:\\desktop" counter = 0 file in os.listdir(rootpath): if file.endswith('.pdf'): os.startfile("%s/%s" %(rootpath, file)) counter = counter + 1 print counter
or without editing main code
import arcpy,fnmatch,os rootpath = r"d:\desktop" pattern = '*.pdf' counter = 0 root, dirs, files in os.walk(rootpath): filename in fnmatch.filter(files, pattern): os.startfile("%s/%s" %(rootpath,filename)) counter = counter + 1 print counter
Comments
Post a Comment