Open the latest file

Now I use the script “system.file.openFile(‘pdf’,‘D:\reports\PT_Report\PT_Report_2017-09-20_17_45_33.pdf’)”,or "system.file.openFile(‘pdf’,'D:\reports\PT_Report"but I can’t open a pdf file,after open a file dialog box, select the file, but can not open the PDF file,why?
This pdf file takes time as the file name, the folder has a lot of such PDF files, I need to query the latest file and open it, how should I do ?

It would be easy to do this with some python code…

something like the below example would work, then pass the latest file into the openFile()

import glob
import os

list_of_files = glob.glob('/path/to/folder/*') # * means all if need specific format then *.csv
latest_file = max(list_of_files, key=os.path.getctime)
print latest_file

Hi , now I can use this find a latest pdf file like this , then I use :
os.popen(r’“D:\Program Files\Foxit Software\Foxit Reader\FoxitReader.exe” filename1’) , filename1 is the file path"D:\reports\PT_Report\PT_Report_2017-09-26_01_01_00.pdf" , I can’t open it , but use “os.popen(r’“D:\Program Files\Foxit Software\Foxit Reader\FoxitReader.exe” D:\reports\PT_Report\PT_Report_2017-09-26_01_01_00.pdf’)”
I can open the file, why?

I suggest checking here for any possible help you may find.