Skip to content

Instantly share code, notes, and snippets.

@andyreagan
Created March 27, 2015 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyreagan/a41b435c188b4204396b to your computer and use it in GitHub Desktop.
Save andyreagan/a41b435c188b4204396b to your computer and use it in GitHub Desktop.
Inspired by my neurotic need to keep my downloads folder clean, naming via Peter Dodds
import os
import datetime
if __name__ == '__main__':
for file in os.listdir('.'):
if not file == 'flowify.py':
t = os.path.getmtime(file)
d = datetime.datetime.fromtimestamp(t)
if not os.path.isdir(d.strftime('/Users/andyreagan/flow/%Y/%m')):
os.mkdir(d.strftime('/Users/andyreagan/flow/%Y/%m'))
os.rename(file,'/Users/andyreagan/flow/{0}/{1}'.format(d.strftime('%Y/%m'),file))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment