Created
          October 15, 2011 21:43 
        
      - 
      
 - 
        
Save ivarvong/1290194 to your computer and use it in GitHub Desktop.  
    exif_scrape_v1
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | 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