<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Overwrite output in python? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/overwrite-output-in-python/m-p/712703#M55283</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think arcpy.env.overwriteOutput will work - arcpy and the 'ArcGIS API for Python' are not the same thing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this might be useful&amp;nbsp;&lt;A href="https://community.esri.com/ideas/11346-overwrite-existing-tile-layer-service-on-arcgis-online"&gt;Overwrite existing Tile Layer Service on ArcGIS Online&lt;/A&gt;&amp;nbsp;. There is an answer from KGerrow a ways down that has an example script&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;maybe try something like:&lt;/P&gt;&lt;PRE style="background-color: #ffffff; border: 0px;"&gt; tile_package = { 'title': ('%s') % p[:-5], 'tags': 'Drone, Imagery', 'type': 'Tile Package', overwrite': 'true'}&lt;/PRE&gt;&lt;P&gt;not sure if that would work, only looked at their script very briefly. But i think digging in to that post will send you in the right direction hopefully&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 31 Jul 2020 16:28:44 GMT</pubDate>
    <dc:creator>NicholasKlein-Baer</dc:creator>
    <dc:date>2020-07-31T16:28:44Z</dc:date>
    <item>
      <title>Overwrite output in python?</title>
      <link>https://community.esri.com/t5/python-questions/overwrite-output-in-python/m-p/712702#M55282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am writing code to cycle through tile packages and publish them to ArcGIS Online. I have tried sticking "arcpy.env.overwriteOutput = True" in a few different places but it doesnt work. The code halts when it finds a duplicate in the output location (here AGOL).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please tell me where it is supposed to go, or if I should use something else like asking if the file exists first.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;from arcgis.gis import GIS
import os
import getpass
import arcpy
import sys

gis = GIS("xxx", "xxx", "xxx")
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r'C:\Users\natb0\OneDrive - drycreekeng.com\GIS\GIS\Data\Dry_Creek\7000_CLS_Farms\drone_flight_072720\TilePackages'
workspace = arcpy.env.workspace

for p in arcpy.ListFiles("*"):
 print (p[:-5])
 data_file_location = workspace + "\\" + p
 tile_package = { 'title': ('%s') % p[:-5], 'tags': 'Drone, Imagery', 'type': 'Tile Package'}
 add_tile_package = gis.content.add(tile_package, data = data_file_location)
 publish_tile_package = add_tile_package.publish()
 arcpy.env.overwriteOutput = True 
 publish_tile_package.move(folder= 'Drone')&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:50:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/overwrite-output-in-python/m-p/712702#M55282</guid>
      <dc:creator>DryCreekEng</dc:creator>
      <dc:date>2021-12-12T16:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite output in python?</title>
      <link>https://community.esri.com/t5/python-questions/overwrite-output-in-python/m-p/712703#M55283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think arcpy.env.overwriteOutput will work - arcpy and the 'ArcGIS API for Python' are not the same thing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this might be useful&amp;nbsp;&lt;A href="https://community.esri.com/ideas/11346-overwrite-existing-tile-layer-service-on-arcgis-online"&gt;Overwrite existing Tile Layer Service on ArcGIS Online&lt;/A&gt;&amp;nbsp;. There is an answer from KGerrow a ways down that has an example script&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;maybe try something like:&lt;/P&gt;&lt;PRE style="background-color: #ffffff; border: 0px;"&gt; tile_package = { 'title': ('%s') % p[:-5], 'tags': 'Drone, Imagery', 'type': 'Tile Package', overwrite': 'true'}&lt;/PRE&gt;&lt;P&gt;not sure if that would work, only looked at their script very briefly. But i think digging in to that post will send you in the right direction hopefully&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2020 16:28:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/overwrite-output-in-python/m-p/712703#M55283</guid>
      <dc:creator>NicholasKlein-Baer</dc:creator>
      <dc:date>2020-07-31T16:28:44Z</dc:date>
    </item>
  </channel>
</rss>

