Jul-11-2021, 02:48 PM
Hi, and thanks for your reply! I just want to learn how this works!
I am running Ubuntu, I never use Windows, I find it terrible.
In my path are 978 files to be found, according to my answer using glob.
I tried your code in my Idle shell.
I am running Ubuntu, I never use Windows, I find it terrible.
In my path are 978 files to be found, according to my answer using glob.
I tried your code in my Idle shell.
Quote:>>> from pathlib import Path
>>> mydir = Path(path)
>>> filelist = [filename for filename in mydir.iterdir() if filename.is_file()]
>>> for filename in filelist:
print(f"\nfilename: {filename.name}")
print(f"file suffix: {filename.suffix}")
print(f"full path: {filename.resolve()}")
print(f"filepath parts: {filename.parts}")
>>> len(filelist)
0
>>> path
'/home/pedro/summer2021/OMR/'