Select to view content in your preferred language

Can ArcGIS Pro ModelBuilder append today's date to output table filename?

8447
12
Jump to solution
04-08-2019 10:05 PM
BenVan_Kesteren1
Deactivated User

I have created a simple tool which finds all properties that lay within a polygon feature (select layer by location), and then exports to a filegeodatabase (Feature class to feature class). 

I am wondering if I can get the output filename to be dynamic, and include today's date in the feature class filename each time it is run?

Currently it exports LandParcelRateParking, if I run it each week it simply overwrites last weeks table. Can I get it to append to the filename to be something like:

LandParcelRateParking05042019

LandParcelRateParking09042019

etc

The model is as per below screenshot:

I am guessing there is something I can do to append the date, but I am missing it.... 

Cheers

12 Replies
KyleConboy
Occasional Contributor

Thanks for the help.  This thread provided the needed solution.  The inline variable referencing the calculated variable was what i wasn't getting before. 

Thanks again:)

curtvprice
MVP Esteemed Contributor
0 Kudos
anonymous55
Frequent Contributor

Hello All

I am trying to create zip file with name and current date. 

example: Land_01242022.zip 

I created shapefile with current date like this Land_todayDate.shp.
But I am having problem to have same format for zip file with all shapefile on it.

I want something like this :

Land_todaydate.zip

I have this code but this just create zip file with name and not adding date to it.

Expression:

zipshape(r"Path","Name")

this function requires the two inputs folder (path to the shapefile) and name (shapefilename, for example if your shapefile is foo.shp, the name should be foo (without the extension). it doesn't work with one input.

code Block:

import os
import glob
import zipfile
def zipshape(folder, name):
    os.chdir(folder)
    zipname = name + ".zip"
    flist = glob.glob(name + "*")
    with zipfile.ZipFile(zipname, "w") as newzip:
        for ff in flist:
            if ff[-4:] != "lock" and ff != zipname: 
                newzip.write(ff)
    return os.path.join(folder, zipname)

Date Type
File

ARM_0-1643056214007.png

I need to run this everyday because I need to add date or maybe just overwrite pervious zip file with new date.

 

0 Kudos