Basic Model Won't Overwrite Existing Data

8082
15
Jump to solution
06-27-2016 08:20 PM
BenVan_Kesteren1
Occasional Contributor III


Hi,

I have a model I created in Model Builder that simply runs several instances of the "Feature Class to Shapefile" tool.

If I run this tool over and over again, it keeps creating new files in the output directory, incrementing the filename by a single digit each time.

For example, if I run the tool three times I will end up with:

  1. Water_mains.shp
  2. Water_mains_1.shp
  3. Water_mains_2.shp

Is there a way I can tell the model builder to overwrite these files instead of creating a unique file name?

I reference these files in several maps, and I thought I was updating the source data for these maps, but each time I run it it creates a new filename so the data source needs to be updated accordingly (not ideal).

Do you know how to force the model to overwrite existing data?

Tags (1)
15 Replies
DanPatterson_Retired
MVP Emeritus

why don't you just delete the old, then create the new? although it is easier to do this in scripting.  Also, if the file is being 'used' anywhere you can't overwrite or delete, so adding results to display for a step means you can't get rid of it

BenVan_Kesteren1
Occasional Contributor III

You are correct, I can delete these files and recreate (time consuming and annoying), and I can script this, but that can be time consuming and that defeats the purpose of me using model builder for 'quick' processes like this.

The shape files are being referenced in AutoCAD files by people in other departments, they are not continually being used, and the chances of someone referencing them and locking them when I run the tool are slim.

JoeBryant2
Occasional Contributor II

Dan,

Would a solution to the data being "locked" from being overwritten/deleted be to instead use the "Truncate Table" tool to remove all the features from the feature class, then use the "Append" tool to re-populate the table? Or would this also fail if, for instance, ArcServer services are referencing the data?

I've heard the above workflow is also preferable as it maintains the metadata for the feature class.

curtvprice
MVP Esteemed Contributor

Jayanta's answer is marked correct. But it sounds like maybe his answer did this not work???

DanPatterson_Retired
MVP Emeritus

overwrite does not overwrite if it is being used as I pointed out and he confirmed in his last comment... don't know if Ben closed it offhand, but what the hey

BenVan_Kesteren1
Occasional Contributor III

Its funny how I come about finding this old post... I just got a new PC, and I forgot how to setup my models so that they overwrote data each time I run it, so I Googled my problem which actually found my original post above. Reading Jayanta's comments allowed me to fix my problem (this time). So I marked it as correct.

I am unsure what the fix was back in 2016, but something else must have been locking my data, not allowing it to be overwritten, but this time around Jayanta fixed my issue, hence the marking it correct.

Everyone can sleep easier now knowing its all good