CreateUniqueName
Summary
Creates a unique name for the specified workspace by appending a number to the input name. This number is incremented until the name is unique. If no workspace is specified, the current workspace is used.
Syntax
CreateUniqueName(base_name, {workspace})
| Parameter | Explanation | Data Type |
|---|---|---|
|
base_name |
The base name used to create the unique name. |
String |
|
workspace |
The workspace used for creation of the unique name. |
String |
Return value
| Data Type | Explanation |
|---|---|
|
String |
A full file path with the unique name. |
Code sample
CreateUniqueName example
Creates a unique name for use with the geoprocessing tools.
import arcpy
# Set workspace
arcpy.env.workspace = "c:/data"
# Create a unique name for the Buffer tool's derived output.
unique_name = arcpy.CreateUniqueName("temp.shp")
# Use unique name for Buffer Tool output dataset name.
arcpy.analysis.Buffer("roads.shp", unique_name, "100 feet")
# Clip output from Buffer tool with County Boundary to obtain buffered roads
# in county.
arcpy.analysis.Clip(unique_name, "county.shp", "clipped_roads.shp")