Skip to content

Instantly share code, notes, and snippets.

@ivarvong
Created October 15, 2011 21:43
Show Gist options
  • Save ivarvong/1290194 to your computer and use it in GitHub Desktop.
Save ivarvong/1290194 to your computer and use it in GitHub Desktop.
exif_scrape_v1
import glob, subprocess
f = open('tally_out.txt', 'w')
base = "/Users/ivar/Pictures/"
directories = glob.glob(base+"11*.*");
def doStuff(file):
exifoutput = subprocess.check_output(["exiftool","-fast","-LensModel","-FocalLength","-Aperture","-FocusDistanceLower",file])
exifoutput = exifoutput.split("\n")
lens = focallength = aperture = dist = " "
try:
lens = exifoutput[0].split(":")[1]
focallength = exifoutput[1].split(":")[1]
focallength = focallength.split("mm")[0]
aperture = exifoutput[2].split(":")[1]
dist = exifoutput[3].split(":")[1]
dist = dist.split("m")[0]
except:
pass
#print "oops"
strout = focallength.strip()+"\t"+dist.strip()+"\t"+aperture.strip()+"\t"+lens.strip()+"\t"+file.strip()
print strout
f.write(strout+"\n")
def scanDir(base, directory):
#print base, directory, "in scanDir"
jpgs = glob.glob(directory+"/*.JPG")
raws = glob.glob(directory+"/*.CR2")
for jpg in jpgs:
doStuff(jpg)
for raw in raws:
doStuff(raw)
for directory in directories:
scanDir(base, directory)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment