import pyexiv2
import os
print "Enter the full path to the directory that your images are conatined in."
print "-------------------------------------------"
newFileObj = open('C:\\users\\wilson\\desktop\\Metadata.csv', 'w')
targ_dir = raw_input('Path: ')
targ_files = os.listdir(targ_dir)
def getEXIFdata (imageFile):
if imageFile.endswith(".db"):
f = 1
else:
EXIFData = pyexiv2.ImageMetadata(imageFile)
EXIFData.read()
CamMake = EXIFData['Exif.Image.Make']
DateTime = EXIFData['Exif.Image.DateTime']
CamModel = EXIFData['Exif.Image.Model']
for image in targ_files:
getEXIFdata(targ_dir+"\\"+img)
newFileObj.write(DateTime+' , '+CamMake+' , '+CamModel+'\r\n')
newFileObj.close()
end = raw_input("Press Enter to Finish: ")
This is what I have so far, but I just dont understand how to actually get the data into the file. It crates the file, but it is just blank. I've tried moving around the bottom for, but I just can't seem to get it to work. I am new to python, so please if you could keep it simple when you hint at what I should do.
If you want to get data of exif, use
.valueto get value of data. Here is an example.run this code like this
If you want to loop files in directory, I think you can figure it out by yourself.