-
-
Save viniciusbig/0da619ecc162d48136a903f0c3da270b to your computer and use it in GitHub Desktop.
Script to organize pictures uploaded from Mobile Devices to Dropbox's Camera 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
################################################################################################ | |
# | |
# Script to organize pictures uploaded from Mobile Devices to Dropbox's Camera Upload folder | |
# | |
# Daniel Spillere Andrade - www.danielandrade.net | |
# | |
################################################################################################ | |
import os, time | |
import glob | |
#Define Pictures Folder | |
#You may have to change this! | |
folder = '/Users/admin/Dropbox/Camera Uploads/' | |
fileFormats = ['JPG','jpg', 'MOV', 'mov', 'PNG', 'png', 'mp4', 'MP4']; | |
months = ['January','February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] | |
picPath = [] | |
#Generate list of files | |
for formats in fileFormats: | |
picPath = picPath + glob.glob(folder + "*."+formats) | |
for files in picPath: | |
picName = files.split('/') | |
filename = picName[-1][:-4].split(' ') | |
date = filename[0].split('-') | |
hour = filename[1] | |
dateYear = date[0] | |
dateMonth = date[1] | |
dateDay = date[2] | |
month = months[int(dateMonth)-1] | |
monthNum = str(int(dateMonth)).zfill(2) | |
#folder exists? if not, create them! | |
if not os.path.exists(folder + dateYear): | |
print 'Making dir:' + folder + dateYear | |
os.makedirs(folder + dateYear) | |
if not os.path.exists(folder + dateYear + '/' + monthNum + '-' + month): | |
print 'Making dir:' + folder + dateYear + '/' + monthNum + '-' + month | |
os.makedirs(folder + dateYear + '/' + monthNum + '-' +month) | |
#Move files | |
print 'Movendo: ' + files + ' --> ' + folder + dateYear + '/' + monthNum + '-' + month + '/' | |
os.rename(picName[-1],folder + dateYear + '/' + monthNum + '-' + month + '/' + picName[-1]) | |
print "Done :)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment