Need to rename multiple shapefiles with attribute values

812
2
05-22-2012 06:58 PM
chrisfernandez
New Contributor
Greetings,

I'm at a bit of a loss and need some help please.

I'm creating a simple model to create masks from features in a shapefile.  I select by attribute, then do a buffer so that each buffered feature becomes its own shapefile.  Now my problem is that I need to rename those individual buffered shapefiles a value from the its attribute table.  All this is being done in model builder as I'm looking at around 500 new shapefiles to be created, for this iteration of the model.  The value is a short string, nothing fancy, just a simple code.  I would prefer to the following sequence: Iterate -->Buffer -->Rename -->More stuff ---> rince repeat.  

I've been racking my brain and searching online but can't find anything that really works for what I need.  If anyone can help me out it'd be greatly appreciated.

Cheers,
Tags (2)
0 Kudos
2 Replies
MathewCoyle
Frequent Contributor
You can pass the attribute of your where clause as a variable and inject that into the filename.
Something along these lines.
attributeList = [1,2,3,4]
queryField = "FIELD_NAME"
for attribute in attributeList:
    where = "{0} = {1}".format(queryField,attribute)
    arcpy.Buffer_analysis(input,output+attribute,buffer_dist)
0 Kudos
HollySmith
New Contributor III
I would also like to know how to do this. I have a list of shapefiles, all with one row in and I want to rename the shapefile using one of the fields.
The explanation above is very vague...

Any help would be appreciated.
Holly
0 Kudos