I need some help putting the date in the filenames. Here's the working code I have so far.
import arcpy, sys
import exifread
from exifread import exif
import os
import time
from datetime import datetime
im = r"path\to\DOT_SignInventory"
for root, dirnames, filenames in os.walk(im):
for fname in filenames:
if fname.endswith('.JPG'):
with open(os.path.join(root, fname), 'rb') as image:
exif = exifread.process_file(image)
dt = str(exif['EXIF DateTimeOriginal'])
ds = time.strptime(dt, '%Y:%m:%d %H:%M:%S')
nt = time.strftime("%m/%d/%Y",ds)
print("Photo:{} Date Taken:{}".format(fname, "_" + nt))
I've tried these couple things after the print statement, but no cigar:
new_file = fname + nt + ".jpg"
f = open(fname.format(nt), "w")
f.write(fname + nt)
f.close