<?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 Exporting attachments (photos) from AGOL  in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/exporting-attachments-photos-from-agol/m-p/637989#M49716</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm currently working through how to export attachments from a layer on AGOL. There is only one thing I am looking for: How to make the file names match that of IDs from a field. Basically I have a list of IDs in a field called {SeasonalMeter}. I want the file names to mirror these IDs. Currently my file names are ATT###_attachment1.jpg where I'd like them to be like this for example: P70344613-H_attachment1 (P70344613-H is a value in my SeasonalMeter field column). The end goal is to bulk dump these attachment into our existing system based on these IDs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've used the following python code and instructions from the following:&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en/technical-article/000011912"&gt;https://support.esri.com/en/technical-article/000011912&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from arcpy import da&lt;BR /&gt;import os&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;inTable = arcpy.GetParameterAsText(0)&lt;BR /&gt;fileLocation = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with da.SearchCursor(inTable, ['DATA', 'ATT_NAME', 'ATTACHMENTID']) as cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for item in cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attachment = item[0]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filenum = "ATT" + str(item[2]) + "_"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;filename = filenum + str(item[1])&lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; open(fileLocation + os.sep + filename, 'wb').write(attachment.tobytes())&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del item&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del filenum&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del filename&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del attachment&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not a programmer/ developer and do not know python. I assume that where it shows filename = filenum + str(item[1]) I would need to replace it with something to the affect&amp;nbsp;-&amp;gt;&amp;nbsp;&lt;STRONG&gt;filename = {SeasonalMeter}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not familiar with coding syntax that would make this happen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will continue researching but I know this forum has always been a great help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Feb 2019 19:48:06 GMT</pubDate>
    <dc:creator>DaveStewart1</dc:creator>
    <dc:date>2019-02-13T19:48:06Z</dc:date>
    <item>
      <title>Exporting attachments (photos) from AGOL</title>
      <link>https://community.esri.com/t5/python-questions/exporting-attachments-photos-from-agol/m-p/637989#M49716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm currently working through how to export attachments from a layer on AGOL. There is only one thing I am looking for: How to make the file names match that of IDs from a field. Basically I have a list of IDs in a field called {SeasonalMeter}. I want the file names to mirror these IDs. Currently my file names are ATT###_attachment1.jpg where I'd like them to be like this for example: P70344613-H_attachment1 (P70344613-H is a value in my SeasonalMeter field column). The end goal is to bulk dump these attachment into our existing system based on these IDs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've used the following python code and instructions from the following:&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en/technical-article/000011912"&gt;https://support.esri.com/en/technical-article/000011912&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from arcpy import da&lt;BR /&gt;import os&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;inTable = arcpy.GetParameterAsText(0)&lt;BR /&gt;fileLocation = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with da.SearchCursor(inTable, ['DATA', 'ATT_NAME', 'ATTACHMENTID']) as cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for item in cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attachment = item[0]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filenum = "ATT" + str(item[2]) + "_"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;filename = filenum + str(item[1])&lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; open(fileLocation + os.sep + filename, 'wb').write(attachment.tobytes())&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del item&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del filenum&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del filename&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del attachment&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not a programmer/ developer and do not know python. I assume that where it shows filename = filenum + str(item[1]) I would need to replace it with something to the affect&amp;nbsp;-&amp;gt;&amp;nbsp;&lt;STRONG&gt;filename = {SeasonalMeter}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not familiar with coding syntax that would make this happen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will continue researching but I know this forum has always been a great help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Feb 2019 19:48:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-attachments-photos-from-agol/m-p/637989#M49716</guid>
      <dc:creator>DaveStewart1</dc:creator>
      <dc:date>2019-02-13T19:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting attachments (photos) from AGOL</title>
      <link>https://community.esri.com/t5/python-questions/exporting-attachments-photos-from-agol/m-p/637990#M49717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This thread may give you some ideas: &lt;A _jive_internal="true" href="https://community.esri.com/thread/216514-is-it-possible-to-use-a-field-for-the-filename-of-an-attachment-export"&gt;Is it possible to use a field for the filename of an attachment export?&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Feb 2019 22:10:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-attachments-photos-from-agol/m-p/637990#M49717</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2019-02-13T22:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting attachments (photos) from AGOL</title>
      <link>https://community.esri.com/t5/python-questions/exporting-attachments-photos-from-agol/m-p/637991#M49718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Randy!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ended up using this python code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from arcpy import da&lt;BR /&gt;import os&lt;/P&gt;&lt;P&gt;inTable = arcpy.GetParameterAsText(0)&lt;BR /&gt;fileLocation = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;with da.SearchCursor(inTable, ['DATA', 'ATT_NAME', 'ATTACHMENTID', 'SeasonalMeter2']) as cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for item in cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attachment = item[0]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filenum = "ATT" + str(item[2]) + "_"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filename = filenum + str(item[3])&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; open(fileLocation + os.sep + filename, 'wb').write(attachment.tobytes())&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del item&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del filenum&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del filename&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del attachment&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just a minor tweak. One thing I had to do was join the Seasonal_Meters__ATTACH table to the data that has the actual field I wanted to include. Then I added a new field to the table, used field calculator to transfer values over (I was having a hard time editing the source), removed the join and ran the script. Another thing, when I exported the files they did not have file extensions. This was easily remedied by another bat file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@echo off&lt;/P&gt;&lt;P&gt;ren * *.jpeg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm sure you could include that in the original python code as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2019 16:40:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-attachments-photos-from-agol/m-p/637991#M49718</guid>
      <dc:creator>DaveStewart1</dc:creator>
      <dc:date>2019-02-14T16:40:46Z</dc:date>
    </item>
  </channel>
</rss>

