Last active
December 20, 2015 19:39
-
-
Save dansku/6184950 to your computer and use it in GitHub Desktop.
Organizing Pictures from BitCasa Upload Folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Organize Iphone Photos by Year -> Month | |
# August, 08, 2013 - Daniel Spillere Andrade | |
# www.DanielAndrade.net | |
import os, time | |
import glob | |
#Define Pictures Folder | |
folder = '/Volumes/Bitcasa Infinite Drive/Uploads/' | |
fileFormats = ['JPG','jpg', 'MOV', 'mov', 'PNG', 'png', 'mp4', 'MP4']; | |
picPath = [] | |
#Generate list of files | |
for formats in fileFormats: | |
picPath = picPath + glob.glob(folder + "*."+formats) | |
for files in picPath: | |
date = time.ctime(os.path.getmtime(files)).split() | |
year = date[4] | |
month = date[1] | |
#folder exists? | |
if not os.path.exists(folder + year): | |
os.makedirs(folder + year) | |
if not os.path.exists(folder + year + '/' + month): | |
os.makedirs(folder + year + '/' + month) | |
#Move files | |
x = len(files.split('/')) | |
print 'Movendo: ' + files + ' --> ' + folder + year + '/' + month + '/' + files.split('/')[x-1] | |
os.rename(files,folder + year + '/' + month + '/' + files.split('/')[x-1]) | |
print "Done :)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment