Autofill date in file name

914
1
09-16-2020 09:05 AM
ThomMullinaux
New Contributor

I'm running a model and I do this on a daily basis with data that changes on the day.  I would like to be able to have Arc automatically fill in the date in the filename with just a DDMMM (Day Month) or something similar in the file name, instead of me manually editing the six output files in model builder prior to running it. 

Essentially I would like the file to look like "example_16SEP.shp" today, and tomorrow it would say "example_17SEP.shp" as the output.

Is this a thing I can do in Arc?  I'm sure there's a script somewhere, I just can't seem to find it!

Thanks!

0 Kudos
1 Reply
JayJohnsonWashoeCounty
Occasional Contributor III

This is actually pretty slick in ModelBuilder.

Put in a "Calculate Value" like this, with the expression = time.strftime("%Y%m%d") and the output name "Today" (output name can be whatever you like).

I make the "Today" output a precondition to something early in the model, so I know it will run before the model gets to the point where I need it.

Next, name your final model outputs something like this c:\temp\OutputOne%Today%  

The %Today% will grab the value from your Calculate Value operation and make it part of the filename.

Jay

Jay
Washoe County GIS
0 Kudos