I am using an inline variable substiution to alter a field name. I do this within an iteration model in model builder. The inline variable is the name of the feature class which I use as my input for each iteration. When I am altering the field name I would like to only use the first part of the inline variable. To explain this a bit better, here is the name structure of my feature classes:
- SA_05_Walk_CBR
- SA_10_Walk_CBR
- SA_05_Bike_CBR
- SA_10_Bike_CBR
- SA_05_Driv_CBR
- SA_10_Driv_CBR
- SA_05_Walk_PJC
- SA_10_Walk_PJC
- SA_05_Bike_PJC
- SA_10_Bike_PJC
- SA_05_Driv_PJC
- SA_10_Driv_PJC
- etc.
(Note that all feature class names have the exact same amount of characters for each part of the names)
Within my iterator, these feature class names represent my inline variable substitution string (called "count_field" in my model, see picture).
When I use the iterator, I join all the SA_xx_xxxx with a point feature class where I use the last three letters of the feature class name as a wilcard (e.g. "star_CBR"). For my next iteration I do the exact same thing but then using "star_PJC" as my new wildcard. These iterations work fine without any problems and it is also the reason why my feature classes need to end with "*_xxx".
Next in my iteration, I alter a certain field name so that they can be differentiated within the table of the feature class. Currently I use this in-line variable subsitution to rename the field (e.g. "SJ_Count_%count_field%"). Also this process works fine. Here is a picture of the alter field window:
(Please ignore the explanation mark; this picture is pure for a demo)
The thing what I want to do, however,is that it only uses part of the inline variable to alter my field name. The last 4 letters of my inline variable (e.g. "_CBR") can be removed within my new field name. So a field name would be called, for example, "SJ_Count_SA_05_Bike"
I have tried in renaming my field name again but I haven't found a way to remove the last 4 characters through an iteration. Anyone any ideas how I could do this in an efficient way? Using python within the alter field tool does not seem to be an option (as seen from alter field tool window picture). Here is a picture of my model: