Autumn! Or Fall as they call it here. Some nice sunsets and the leaves are changing, and it's getting much colder to be standing around as the sun goes down, that's for sure...
![]() |
Mr Strader gets his shot |
# Grant Herbert 29/10/2011
# Python script to manage RAW files imported from 40D.
#
# Looks through the folders in my Pictures folder.
# If it finds RAW files (cr2),
# creates a RAW subfolder (if needed) and moves them into it.
# Also creates Editing and Uploaded folders if an image file is found
import os, shutil
start_folder = "C:\Users\Grant\Pictures"
print "----------Starting------------"
#create RAW folder
def c_RAW(p):
p1 = str(p) + '\\RAW'
if not os.path.exists(p1):
print "Creating", p1
os.mkdir(p1)
#create Edited, Uploaded folders
def c_Edit(pp):
p2 = str(pp) + '\\Edited'
p3 = str(pp) + '\\Uploaded'
if not os.path.exists(p2):
print "Creating", p2
os.mkdir(p2)
if not os.path.exists(p3):
print "Creating", p3
os.mkdir(p3)
#find RAW files
def findRAWf(path):
count = 0 #initialise count
filelist = os.listdir(path)
for f in filelist:
f_lower = f.lower() #ignore case
if f_lower.endswith(('.cr2', '.jpg', '.jpeg', '.tif', '.tiff')): #search for any image files
c_Edit(path)
if f_lower.endswith('.cr2'): #search for Canon RAW files
c_RAW(path) #RAW file found, create folder if needed
#rename file using shutil to keep metadata if possible
shutil.move(path + '\\' + f, path + '\\RAW\\' + f)
count = count + 1
if count > 0:
print count, "RAW files found and moved"
#search folders in start_folder
#ignore files
for name in os.listdir(start_folder):
folder = start_folder + '\\' + str(name)
if os.path.isdir(str(folder)): #is a directory
print "searching", folder
findRAWf(folder)
#when finished
print "----------Completed------------"