Instead of doing multiple replaces of any character you may get, I suggest using the ValidateTableName arcpy method. This requires that you write a little python script in the code block, but it is likely to be more effective. Note only grids have the 10-character limitation. Here I'm using the python os module instead of the Parse Path tool in modelbuilder to take the path apart and put it together.I am convinced a good understanding of Calculate Value and a little python is necessary to leverage the full power of ModelBuilder.Calculate Value toolExpression: ValidatePath(r"%Output Raster%")
(The "r" and quotes are required -- so the path is read correctly.) Code block: def ValidatePath(ds):
import arcpy
import os
# extract pathname
dspath = os.path.dirname(ds)
dsname = os.path.basename(ds)
# fix weird characters in dataset name
dsname = arcpy.ValidateTableName(dsname,dspath)
# for grids, truncate to 10 characters
dsname = dsname[:10]
return os.path.join(dspath,dsname)