<?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: Coding Help! in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/coding-help/m-p/697223#M54038</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've tried the code and it works well, but I have a slight problem. A few of the points don't have attachments, but I'm not sure where. So the pictures coming out don't match up with the points with the same name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to identify these points?&lt;/P&gt;&lt;P&gt;Or skip these for the renaming?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Mar 2015 16:33:40 GMT</pubDate>
    <dc:creator>SamPlant</dc:creator>
    <dc:date>2015-03-06T16:33:40Z</dc:date>
    <item>
      <title>Coding Help!</title>
      <link>https://community.esri.com/t5/python-questions/coding-help/m-p/697220#M54035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a FGDB for a project at work.&lt;/P&gt;&lt;P&gt;We have plotted points for road signs and collected various attributes for each point.&lt;/P&gt;&lt;P&gt;We also have a picture attachment for each point.&lt;/P&gt;&lt;P&gt;The information was collected on the Collector app and has now been downloaded.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I now need to do a few things to the data.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to populate a field named 'USSR' with an automatic incremental number followed by the letter 'A', starting at a set number i.e. 7000A, 7001A, 7002A etc.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then need the attachments to be saved and named as '7000A.jpg', '7001A.jpg', '7002A.jpg' etc.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I need the 'Photo' field to be filled with the photo name i.e. '7000A.jpg'&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been looking for some Python script I can run from ArcMap to batch rename and update for me, but I'm struggling to find anything I can use.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone could help me I'd be very grateful.&lt;/P&gt;&lt;P&gt;I have a very limited knowledge of coding and have no idea where to start.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Sam Plant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2015 11:34:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/coding-help/m-p/697220#M54035</guid>
      <dc:creator>SamPlant</dc:creator>
      <dc:date>2015-03-04T11:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Help!</title>
      <link>https://community.esri.com/t5/python-questions/coding-help/m-p/697221#M54036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sam,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example on how to do this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
from arcpy import env
env.workspace = r"C:\temp\python\test.gdb"

#Update USSR and Photo field
fc = "Airports"
field1 = "USSR"
field2 = "Photo"

x = 7000
y = 0

rows = arcpy.UpdateCursor(fc)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(field1, str(x + y) + "A")
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(field2, str(x + y) + "A.JPG")
&amp;nbsp;&amp;nbsp;&amp;nbsp; y += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)

del row, rows


#Save attachments
tbl = r"C:\Temp\Python\Test.gdb\Airports__ATTACH"
fldBLOB = 'DATA'
fldAttName = 'ATT_NAME'
outFolder = r"C:\Temp\Python\Attachments"

x = 7000
y = 0

with arcpy.da.SearchCursor(tbl,[fldBLOB,fldAttName]) as cursor:
&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binaryRep = row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; open(outFolder + os.sep + str(x + y) + "A.JPG", 'wb').write(binaryRep.tobytes())
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y += 1

del cursor
print 'Finished'&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:20:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/coding-help/m-p/697221#M54036</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-12T05:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Help!</title>
      <link>https://community.esri.com/t5/python-questions/coding-help/m-p/697222#M54037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks that's brilliant.&lt;/P&gt;&lt;P&gt;I'll have a go and see if I can get it working.&lt;/P&gt;&lt;P&gt;I have manually had to rename 4000 signs from a different program, and it takes a long time...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2015 13:19:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/coding-help/m-p/697222#M54037</guid>
      <dc:creator>SamPlant</dc:creator>
      <dc:date>2015-03-04T13:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Help!</title>
      <link>https://community.esri.com/t5/python-questions/coding-help/m-p/697223#M54038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've tried the code and it works well, but I have a slight problem. A few of the points don't have attachments, but I'm not sure where. So the pictures coming out don't match up with the points with the same name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to identify these points?&lt;/P&gt;&lt;P&gt;Or skip these for the renaming?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 16:33:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/coding-help/m-p/697223#M54038</guid>
      <dc:creator>SamPlant</dc:creator>
      <dc:date>2015-03-06T16:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Help!</title>
      <link>https://community.esri.com/t5/python-questions/coding-help/m-p/697224#M54039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try the code below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note:&amp;nbsp; In this example, Global IDs exist, so the relationship between the feature class and attachments table is based off of the GLOBALID and REL_GLOBALID fields.&amp;nbsp; If your data does not contain GlobalIDs, the relationship will exist between the OBJECTID and REL_OBJECTID field.&amp;nbsp; So, you will need to update line 10 to "REL_OBJECTID" and line 20 to row.OBJECTID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os&amp;nbsp; 
from arcpy import env&amp;nbsp; 
env.workspace = r"C:\temp\python\test.gdb"&amp;nbsp; 
&amp;nbsp; 
#Update USSR and Photo field&amp;nbsp; 
fc = "Airports"
tbl = "Airports__ATTACH"
field1 = "USSR"&amp;nbsp; 
field2 = "Photo"
relateField = "REL_GLOBALID"
fldBLOB = 'DATA'&amp;nbsp; 
fldAttName = 'ATT_NAME'&amp;nbsp; 
outFolder = r"C:\Temp\Python\Attachments" 
&amp;nbsp; 
x = 7000&amp;nbsp; 
y = 0&amp;nbsp; 
&amp;nbsp; 
rows = arcpy.UpdateCursor(fc)&amp;nbsp; 
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; globalID = row.GlobalID
&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor(tbl,[fldBLOB,fldAttName,relateField]) as cursor:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row2 in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row2[2] == globalID:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(field1, str(x + y) + "A")&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(field2, str(x + y) + "A.JPG") 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binaryRep = row2[0]&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; open(outFolder + os.sep + str(x + y) + "A.JPG", 'wb').write(binaryRep.tobytes())&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; y += 1&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&amp;nbsp; 
&amp;nbsp; 
del row, rows, row2, cursor
&amp;nbsp; 
&amp;nbsp;&amp;nbsp; 
print 'Finished' &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:20:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/coding-help/m-p/697224#M54039</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-12T05:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Help!</title>
      <link>https://community.esri.com/t5/python-questions/coding-help/m-p/697225#M54040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Brilliant. I managed to figure out a way around it, by splitting the table in two and saving separately, but this will help me the next few times I need to do it, and save me time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thankyou&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Mar 2015 14:48:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/coding-help/m-p/697225#M54040</guid>
      <dc:creator>SamPlant</dc:creator>
      <dc:date>2015-03-09T14:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: Coding Help!</title>
      <link>https://community.esri.com/t5/python-questions/coding-help/m-p/697226#M54041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can this code be adapted to bulk rename picture attachments collected with Collector for ArcGIS/ArcGIS Online?&amp;nbsp; The picture attachments&amp;nbsp;have been downloaded locally but need to be renamed based on feature class ID attribute (e.g. Stop_ID in a point feature class).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Oct 2017 12:46:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/coding-help/m-p/697226#M54041</guid>
      <dc:creator>LarryJahn</dc:creator>
      <dc:date>2017-10-19T12:46:24Z</dc:date>
    </item>
  </channel>
</rss>

