<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">import</SPAN> os
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"C:\Users\natb0\OneDrive - drycreekeng.com\GIS\GIS\Data\Dry_Creek\TerrAvion_Imagery\062319"</SPAN>
input_folder <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace
<SPAN class="keyword token">for</SPAN> p <SPAN class="keyword token">in</SPAN> os<SPAN class="punctuation token">.</SPAN>listdir<SPAN class="punctuation token">(</SPAN>input_folder<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
p<SPAN class="punctuation token">.</SPAN>replace<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"CIR_4326"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"RGB_062319"</SPAN><SPAN class="punctuation token">)</SPAN>
p<SPAN class="punctuation token">.</SPAN>replace<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"TIRS_T_4326"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Temp_062319"</SPAN><SPAN class="punctuation token">)</SPAN>
p<SPAN class="punctuation token">.</SPAN>replace<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"NDVI_NDVI_2_4326"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"NDVI_062319"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> p<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>I have to download 48 images from a website weekly, and I would like to write a script to rename the files to something more user friendly and understandable. For each farm field (16 fields total), I download 3 images (#farmfield_TIRS_T_4326.tiff, #farmfield_CIR_4326.tiff, and #farmfield_NDVI_NDVI_2_4326.tiff), where TIRS = temperature, CIR = infrared, and NDVI is NDVI. For each file name, I would like to replace "TIRS_T_4326" with "Temp_062319", "CIR_4326" with "RGB_062319", and "NDVI_NDVI_2_4326" with "NDVI_062319". When I run the code, it runs fine but the file names do not change. So Im guessing .replace is the wrong argument. Does anyone know what I should use instead? My goal is to do a find a replace on the file names.