Created
March 22, 2018 11:25
-
-
Save stepheweffie/314bad717b61cdc77fef1619c5e93d36 to your computer and use it in GitHub Desktop.
Get the sorted directory by file creation dates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
directory = "/dir/" | |
os.chdir(directory) | |
files = filter(os.path.isfile, os.listdir(directory)) | |
files = [os.path.join(directory, f) for f in files] # add path to files | |
files.sort(key=lambda x: os.path.getmtime(x)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment