import os import arcpy from arcpy import env RASTER_DIR = 'C:/GIS_Working/QQ/Temp_monthly_means_gridded/' env.workspace = RASTER_DIR rasters = arcpy.ListRasters() for raster in rasters: fileName, fileExtension = os.path.splitext(raster) fileNameParts = fileName.split('_') if len(fileNameParts) >= 5: compactFileName = fileNameParts[1] + fileNameParts[4] + fileExtension arcpy.Rename_management(raster, compactFileName)
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.