Sep-23-2021, 04:46 PM
(This post was last modified: Sep-24-2021, 01:09 PM by Yoriz.
Edit Reason: Added code tags
)
Hello all,
I'm having a hard time getting this script across the finish line. I want to display only the last 20 file paths in the given directory, but I keep hitting a wall. Right now, it prints all the file paths in the folder, but I only want to the last 20. Can anyone help point me in the right direction?
I'm having a hard time getting this script across the finish line. I want to display only the last 20 file paths in the given directory, but I keep hitting a wall. Right now, it prints all the file paths in the folder, but I only want to the last 20. Can anyone help point me in the right direction?
1 2 3 4 5 6 7 |
import glob import os from pathlib import Path path = (r '\\directory' ) files = filter ( lambda filepath: filepath.is_file(), Path(path).glob( '*' )) for file in files: print ( file .absolute()) |