I am using 'ParsePath' in a model and for 'Name' it returns whatever layer name I have given the layer in the TOC and for 'Path' it returns the group the layer is in (if it is in one). This is not helpful.
I would like to get the real file name - ie. DataPoints, not 'Points Collected in the field on 12/13/2023'
If the user selects the file on disk, this problem is solved, but I'd rather have the convenience of pulling the layer in from the table of contents.
Is it possible with ParsePath to get the 'actual' file information? This can be done with Python, and I may make a Python tool, but just wondering of ModelBuilder ParsePath can work here.
Thank you,
Randy McGregor
Solved! Go to Solution.
Hi Randy,
I have a suggestion:
Instead of using Parse Path, you could try using something like this with Calculate Value:
Expression: FileName
Code Block:
LayerInput = '%LayerInput%'
desc = arcpy.Describe(LayerInput)
FileName = desc.baseName
The resulting Value should be the name of your actual file name.
Depending on your needs, you could change baseName to these other options available: https://pro.arcgis.com/en/pro-app/3.1/arcpy/functions/describe-object-properties.htm
Hi Randy,
I have a suggestion:
Instead of using Parse Path, you could try using something like this with Calculate Value:
Expression: FileName
Code Block:
LayerInput = '%LayerInput%'
desc = arcpy.Describe(LayerInput)
FileName = desc.baseName
The resulting Value should be the name of your actual file name.
Depending on your needs, you could change baseName to these other options available: https://pro.arcgis.com/en/pro-app/3.1/arcpy/functions/describe-object-properties.htm
Thank you! That worked. I appreciate it. Ended up looking like this: