1

I am using iterate raster in ModelBuilder to create hillshade and slope simultaneously for many rasters within one folder.

My problem is when I name the output files.

Whenever I use, %Name%, the model fails because the resulting output names include the file extension.

If I use %n%, it only creates one file.

Is there another way of naming output files where the original file name is retained but without the file extension?

1 Answer 1

2

The Parse Path (ModelBuilder) should be able to meet your requirement.

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.

If not, then a diagram of your model and more details would be helpful to try and provide a more targeted Answer.

4
  • Oh thanks, it worked, however, when I tried to combine Parse path with calculate value (because I also need to remove the hyphen from my filename), the resulting outputs do not match the initial output. I'm still trying to figure it out Commented Feb 12, 2014 at 8:28
  • @user26845 You need to add a precondition from the parse output to a tool so that the parse output does not get ahead of the tool output.
    – Aaron
    Commented Oct 31, 2014 at 22:59
  • I though this was going to be the solution to my problem but it did not work. The file I'm trying to parse is 'safer.A2009241.250m_16_days_NIR_reflectance.tif' and the name I get is 'safer.A2009241'. It's trowing away part of the name.
    – Daniel
    Commented Apr 17, 2015 at 11:30
  • In my case I solved my 'filename with more than two . (dots)' using the Calculate Value tool and the python expression '.'.join(f.split('.')[:-1]), where f is the name variable
    – Daniel
    Commented Apr 17, 2015 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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