Hello!
I think one way you can do this is via a Python script tool.
I would carry out the following:
1: Copy the code below into a Python script:
import arcpy
from datetime import datetime# Module for calculating dates & times
path = arcpy.GetParameterAsText(0) # Receive data from Script tool dialog
gdbName = arcpy.GetParameterAsText(1) # Receive data from script tool dialog
# Calculate the date (you can amend this to add the time also..)
curDate = datetime.now()
year = curDate.year
month = curDate.month
day = curDate.day
gdbNameDate = f"{year}_{month}_{day}_{gdbName}"
#Call the Create File Geodatabase geoprocessing tool
arcpy.arcpy.management.CreateFileGDB(path, gdbNameDate)
2: The lines of code - arcpy.GetParameterAsText() allow the script to receive data from outside of the script. You will pass the geodatabase pathway and its name into the script. GetParameterAsText(0) receives the pathway for the geodatabase while GetParameterAsText(1) receives the chosen name of the geodatabase.
3: Create a Python Script tool in, for example, your project's default toolbox. (Right click the toolbox > New > Script)
This will display the Python Script tool properties dialog. There are 4 tabs down the left hand side.
4: On the General tab, provide a Name & Label for the script tool.
5: On the Parameters tab you need to create 2 parameters here.
The first parameter is the geodatabase pathway.
- Provide a label. This is what the user will see as the title of the parameter on the dialog.
- Select workspace as the datatype. You should set a filter, choosing workspace and then tick File System
The second parameter is the geodatabase name.
- Provide a label. This is what the user will see as the title of the parameter on the dialog.
- Set a default value, for example Streets.gdb.
So:
The ordering of these parameters on the Tool Properties dialog is important as the order on the dialog determines the order in which the values are passed into the script via arcpy.GetParameterAsText()
6: Click the Execution tab and for Script File browse to the location of the python script!
7: Once your are finished double click the Python Script tool:
The script tool dialog will then display.
8: Fill in the dialog parameters and press Run.
That should be everything you need to know... and will create a new file geodatabase with the current date as part of its name...
Have fun ed