I have a model which iterates through a dataset, renames the shapefiles in the dataset and puts the new name of the shapefile into a "source" field in the shapefile. (The new name, used both in Rename and Calculate Source, is '%Name%_%Date%')
When I run it in the Model Builder window, it runs fine. When I run it outside of model builder as a tool, it renames the first file and incorrectly calculates "source" as the new name of the second file, and it renames, but doesn't put any source, in the second file and then errors out saying the first renamed file already exists (which it does because it already created it).
Why is it trying to rename the first file again? And why is it putting the new name for one file into the source field for another file? I thought the iterator takes the first file, runs it through the rest of the model, then the second file, and so on. At least that seems to be how it runs in Model Builder.
At any rate, how can I fix this. I need to be able to run it as a tool outside of Model Builder.