Skip to content

Instantly share code, notes, and snippets.

@songpon
Last active April 17, 2018 10:04
Show Gist options
  • Select an option

  • Save songpon/9c7f5ab7237f988cf3eeec4fa0ffd3ca to your computer and use it in GitHub Desktop.

Select an option

Save songpon/9c7f5ab7237f988cf3eeec4fa0ffd3ca to your computer and use it in GitHub Desktop.
import os
import datetime
import glob
def modification_date(filename):
t = os.path.getmtime(filename)
return datetime.datetime.fromtimestamp(t)
files = glob.glob('*')
for l in files:
if l.endswith('py'):
continue
dt = modification_date(l)
out = dt.strftime("%Y%m%d")
newname = '%s-%s' % ( out,l,)
print newname
os.rename(l, newname)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment