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