Skip to content

Instantly share code, notes, and snippets.

@ronsims2
Created January 19, 2015 01:32
Show Gist options
  • Select an option

  • Save ronsims2/f083114e77d09f302cbf to your computer and use it in GitHub Desktop.

Select an option

Save ronsims2/f083114e77d09f302cbf to your computer and use it in GitHub Desktop.
A simple program that moves archived iPhoto files that are stored on a CD to a directory (you specify) on your PC.
import os
import shutil
class imover:
def __init__(self, loc = '', dest = ''):
self.loc = loc
self.dest = dest
if self.loc != '' and self.dest != '':
self.movefiles()
def movefiles(self, loc = '', dest = ''):
if loc != '':
self.loc = loc
if dest != '':
self.dest = dest
if self.loc != '' and self.dest != '':
#Get list of directories from the root of the cd
for root, dirs, filenames in os.walk(self.loc):
#If not a thumb directory check to see if eligible files are there to move
if root.find("Thumb") == -1 and root.find("Data") == -1:
for f in filenames:
#Complete location (fn) and destination (d) paths
fn = root + "\\" + f
d = self.dest + "\\" + f
shutil.copyfile(fn, d)
print(fn + " copied to " + d + ".")
print("And done.")
return True
else:
print("You must specify a place to grab the files and a place to put the files.")
return False
#Sample use, for windows paths use double forward slash to escape it!!!
#Set loc to the root of the cds photos
loc = "E:\\"
#Set dest to where you want the files to go
dest = "C:\\"
imv = imover(loc, dest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment