[GIS] Model Builder ArcGis Iterate file and rename files

arcgis-desktopfile-geodatabasemodelbuilder

I want to go through a folder and subfolders to copy some files in a gdb. At the moment I have tried to do it using the iterator file and the Copy tool. The problem is all the files have the same name, then I would need to rename and give them a only name before to copy them in the gdb.

I am not too sure how I could rename them automatically, any advice?

Best Answer

Model builder has two built in system variables that you can use with in-line variable substitution to automatically rename files and give them unique names.

From the ESRI documentation on Examples of in-line variable substitution with ModelBuilder system variables:

Using the %i% system variable with in-line variable substitution enter image description here

Using the %n% system variable with in-line variable substitution

enter image description here

If you are using Iterate Feature Classes, you could combine the Name variable with the system variable in some tool's output parameter:

C:\path\to\your.gdb\%Name%_%n%
Related Question