Skip to content

Instantly share code, notes, and snippets.

@exaos
Created January 10, 2013 09:14
Show Gist options
  • Save exaos/4500671 to your computer and use it in GitHub Desktop.
Save exaos/4500671 to your computer and use it in GitHub Desktop.
Split ISO-date to subdirs: e.g. 2012-12-12/*.* ==> 2012/12/12/*.*
import shutil, os, sys
def dest_name(d_name):
d_tmp = d_name.split('-')
if d_tmp and d_tmp[0] != d_name:
return os.path.join('.',*d_tmp)
return None
names = os.listdir(ur'.')
for d in names:
d_dest = dest_name(d)
if d_dest: shutil.move(d, d_dest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment