Why does the Rename tool change the name of a layer file in layer properties?

1727
7
08-16-2017 09:10 AM
MattDeveney
New Contributor III

I used the rename tool to rename a set of layers. However, when I ran it, it renamed them in the catalog tree but not in the Layer Properties or when added to a map.  See screen shots below.  Any help would be appreciated.

0 Kudos
7 Replies
DanPatterson_Retired
MVP Emeritus

When this doesn't work http://pro.arcgis.com/en/pro-app/help/projects/rename-project-items.htm

try this http://pro.arcgis.com/en/pro-app/tool-reference/data-management/rename.htm

but that says it won't rename layers since layers are a reference to a dataset

which is somewhat circular, but my guess would be to rename the dataset first, then make the layer... it would definitely provide less confusion  (the links are for pro, but they are the same for arcmap

0 Kudos
MattDeveney
New Contributor III

Thank you Dan.  Renaming the original dataset will work, however, when I go to save it as a layer file, ArcGIS attaches "_Save_to_Layer_File" at the end of each feature class, hence the need for the renaming process on the layers.  Is there any way to stop it from attaching this to each feature class name?

0 Kudos
DanPatterson_Retired
MVP Emeritus

If doing it with the tool manually, just delete the offending addendum.  If using the tool in a script, you have control on the output filename.  many tools in Arctoolbox append extra bits at the end of a filename... probably so you know what they are, or perhaps to prevent overwriting existing data (as in the case of the copy tool)

0 Kudos
MattDeveney
New Contributor III

I am using all of these tools in a model. Please see the screenshot below.

This is one line of the model which 1) iterates through a gdb does a test to see if a feature class has a specific name, 2) if it does, it creates a feature layer, 3) saves it to a layer file and 4) gives the layer a specific symbology. I am carrying the feature class name through the process using inline variables, but when I try to use an inline variable within the save to layer file, I get an error "Item not found in this collection".  If I leave it blank, it will attach "Save_to_Layer_File".

 

0 Kudos
DanPatterson_Retired
MVP Emeritus

oh... now the model appears... sigh.... I don't suppose you can put in the name you want or pull them from a list... of write a script to do that step.

I will defer to those that use models... and share it with https://community.esri.com/groups/model-builder?sr=search&searchId=25562dca-4508-4180-8c5c-1a4ac33ae...‌ and https://community.esri.com/community/mapping-and-charting?sr=search&searchId=61669a0e-5eb7-4bd5-9807...‌ and https://community.esri.com/community/developers/gis-developers/python?sr=search&searchId=5313a483-a6...‌ to see if  anyone has done anything similar

0 Kudos
MattDeveney
New Contributor III

The same thing happens regardless of being in a model. It happens in running the model, running the Rename Tool by itself, and running it in the python window itself.  Ill look into a list or script.  Thank you.

0 Kudos
curtvprice
MVP Esteemed Contributor

In this model , could you apply symbology before you save to layer file? Then you can save to layer file after the symbology is applied, saving it to the name you want in the first place (no rename required). 

Note when you run Make Feature Layer Model Builder sets a default name but you could define your own and reference it there in the layer name for example %variable%. Same with the layer file name when you save it. That 'variable' model element could be created using Calculate Value or Parse path and then set as a precondition to Make Feature Layer so you ensure the name gets generated before Make Feature Layer is run.

0 Kudos