1

I have seen similar questions but no clear answer and I am afraid that this can't be done in ModelBuilder alone.

Is there a way to truncate the extension off the %name% variable? I am working with .tif and .asc files that I use to resample and do zonal statistics but since they have file extensions the tools throw an error when using %name% and I am forced to use %n% and then rename the files using R. I have tried "%name%"[x:y] as suggested in another question but doesn't work.

Any suggestions? This is ArcMap 10.2 but had the same problem in 10.0

2

You should be able to do this using the Parse Path (ModelBuilder) tool which may have been new at ArcGIS 10.1:

The Parse Path tool parses the input into its file, path, name, or extension. The output can be used as in-line variables in the output name of other tools.

  • thanks so much for this! I should have asked earlier and saved a ton of time coding this in R! – Herman Toothrot Dec 18 '13 at 3:54
  • ok I shouldn't have been so exited so quickly. I am having a problem now that the parsing happens before the iteration moves to the next raster. So result2 has the raster1 name. – Herman Toothrot Dec 18 '13 at 4:21
  • If you think this is part of the same initial Question would you be able to edit that to include more details and a diagram of your model, please? If you think it has moved to a new issue then perhaps research/ask it separately. – PolyGeo Dec 18 '13 at 4:52
2

You could also use "%Name%".replace(".tif","") in Calculate Value in ModelBuilder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.