AnsweredAssumed Answered

How to get just the filename returned using Calculate Field tool

Question asked by sventresca on Oct 9, 2012
Latest reply on Oct 9, 2012 by Wayne_Whitley
I'm sure there is a simple answer to this but I'm not seeing it! I want to populate the field I add with just the file name. The code I have below gives me the entire file path populated into the field I add. How can I extract out just the file name?


import arcpy, os, sys, string from arcpy import env from arcpy.sa import*  arcpy.CheckOutExtension("Spatial") arcpy.env.overwriteOutput = True  # Get input parameters for the Zonal Statistics As Table tool inPath = arcpy.GetParameterAsText(0) zoneField = arcpy.GetParameterAsText(1) rasterList = arcpy.GetParameterAsText(2).split(';') outPath = arcpy.GetParameterAsText(3)  for raster in rasterList:         ZonalStatisticsAsTable(inPath, zoneField, raster, outPath)     arcpy.AddField_management(outPath, "RasName", "TEXT")     arcpy.CalculateField_management(outPath, "RasName", '"'+ raster + '"')

Outcomes