Skip to content

Instantly share code, notes, and snippets.

@stepheweffie
Created March 22, 2018 11:25
Show Gist options
  • Save stepheweffie/314bad717b61cdc77fef1619c5e93d36 to your computer and use it in GitHub Desktop.
Save stepheweffie/314bad717b61cdc77fef1619c5e93d36 to your computer and use it in GitHub Desktop.
Get the sorted directory by file creation dates
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