Modify or use portion of inline variable %Name% from iterator

6287
4
Jump to solution
10-06-2016 03:05 PM
RobertRockwood
New Contributor II

Hi-

I have a model using the 'Iterate Feature' tool.  I am using the %Name% inline variable from the iterator to name my output files.  The %Name% variable takes on the values "All_2014_06", "All_2014_07",.. etc.  I would like to name my files with "Speed_2014_06", "Speed_2014_07", etc. instead... is there a way to alter the %Name% variable or only use a subset of the variable (the date portion) to do this?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertRockwood
New Contributor II

I figured out the solution.  You can use the 'Calculate Value' tool from the 'Insert'>>'Model Builder Tools' menu with the iterator 'Name' variable as an input.  Adding the python script "%Name%"[4: ] will return the character string minus the first 4 characters.  You can then use the result of the tool as your inline variable for naming.

View solution in original post

4 Replies
RobertRockwood
New Contributor II

I figured out the solution.  You can use the 'Calculate Value' tool from the 'Insert'>>'Model Builder Tools' menu with the iterator 'Name' variable as an input.  Adding the python script "%Name%"[4: ] will return the character string minus the first 4 characters.  You can then use the result of the tool as your inline variable for naming.

SUSHILLAMICHHANE
New Contributor

It renamed the first file as 1 and took the name of first input file to rename the second file and so on.

0 Kudos
KristinThorpe1
Occasional Contributor

Hi SUSHIL LAMICHHANE! I know this a really old post but I am experiencing this problem and wondering if you can help me? I have a model that creates a summary table for each unique record in a field. I am using the Calculate Value tool to remove spaces and other invalid characters from the %Value%; my output tables use %Name%. However, the name of the first output is "1" and the second table is what the first table should be and so on. Do you have a solution to this?

curtvprice
MVP Esteemed Contributor

Robert, that is exactly how to do it! The only thing I'd add is if the variable you are using is a pathname (likely to have \ characters in it) you need to escape it, for example:

r"%Path%" + ".tif"
0 Kudos