I want get a list of files name of all pdf files in folder I have my python script.
Now I have this code:
files = [f for f in os.listdir('.') if os.path.isfile(f)]
for f in files:
e = (len(files) - 1)
The problem are this code found all files in folder(include .py) so I "fix" if my script is the last file on the folder (zzzz.py) and later I subtract the last file of the list that are my script.py.
I try many codes for only find .pdf but this the more near I am.
Use the glob
module:
>>> import glob
>>> glob.glob("*.pdf")
>>> ['308301003.pdf', 'Databricks-how-to-data-import.pdf', 'emr-dg.pdf', 'gfs-sosp2003.pdf']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With