Overwrite Existing File - Model Builder

15471
10
10-29-2013 11:47 AM
MikeBly
Occasional Contributor
Hey,

I have a simple model that converts a feature class to shapefile, drops unneeded fields and then reprojects. Thats it.

Problem is the model will not run unless I first go and delete the outputs from any previous run of the model. Is there a way in the final geoprocessing step or another tool that will allow the process to overwrite any existing file?

Simple enough I would think..........

Thanks,

Mike
10 Replies
lelaharrington
New Contributor III

Did you ever get this process completed. i have a similar problem, i am looking to take features from SDE1 and send them to SDE2 and overwrite the features in SDE 2. i tried features to features tool but it doesn overwrite it. it adds a _1 after the feature name.

0 Kudos
TimWitt2
MVP Regular Contributor

Lela,

you could always create your model in modelbuilder and then export it to python. Then you could add code that will check if certain files exist and if they do, delete them. Like this:

env.workspace = "Space where your output will be"
if arcpy.Exists("your feature"):
    arcpy.Delete_management("your featuree")

That's how I do it.

Tim

0 Kudos
lelaharrington
New Contributor III

that is what i am doing is starting in model builder and then exporting out into python after the system is proven. i just can figure out how to get model builder to overwrite the feature rather than add the _1 to it.

0 Kudos
Marco_AlejandroBonilla
Occasional Contributor

for python, i think you must use the command line after importing arcpy: arcpy.env.overwriteOutput = True

0 Kudos
lelaharrington
New Contributor III

if i put the model builder and save it as a python script where would i place this code for it to run? 

Thank you

Lela Harrington

0 Kudos
ShitalDhakal__GISP
Occasional Contributor

Did you figure out where to put your code to run?

0 Kudos
Marco_AlejandroBonilla
Occasional Contributor

Did you try setting your geoprocessing options for overwriting outputs??Captura.JPG

I think this must help

lelaharrington
New Contributor III

where is that located? 

Thank you

Lela Harrington

0 Kudos
Marco_AlejandroBonilla
Occasional Contributor

In the menu bar, click on "geoprocessing", then click on "geoprocessing options"Captura2.JPG

=)