Skip to content

Instantly share code, notes, and snippets.

@christopher-baek
Created July 19, 2015 00:19
Show Gist options
  • Save christopher-baek/d0d37800d4141c50606a to your computer and use it in GitHub Desktop.
Save christopher-baek/d0d37800d4141c50606a to your computer and use it in GitHub Desktop.
generate a new filename based on a file's "last modified" time (in YYYYMMDDHHMMSS format)
import os
import time
def new_filename_from_mtime(filename):
new_filename = time.strftime('%Y%m%d%H%M%S',
time.strptime(
time.ctime(os.path.getmtime(filename))))
return new_filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment