<?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: Export Multiple Shapefiles from TOC in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404102#M23204</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks this works great.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Jan 2013 18:49:08 GMT</pubDate>
    <dc:creator>CraigMcClain</dc:creator>
    <dc:date>2013-01-16T18:49:08Z</dc:date>
    <item>
      <title>Export Multiple Shapefiles from TOC</title>
      <link>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404098#M23200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am looking for a script that will export multiple layers (usually points, lines or polygon) that are open in an mxd to shapefiles. Hopefully a little VB script I can run within Visual Basic Editor that export the top 10 layers or something to that effect. Something faster than individually right clicking on each layer and then Data -&amp;gt; Export Data. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have seen the Export datasets from &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://arcscripts.esri.com/details.asp?dbid=14971" rel="nofollow" target="_blank"&gt;ArcMap TOC (updated 2.2) - ArcGIS 9.3&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Looking for something that works in 10.1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2013 20:36:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404098#M23200</guid>
      <dc:creator>CraigMcClain</dc:creator>
      <dc:date>2013-01-15T20:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: Export Multiple Shapefiles from TOC</title>
      <link>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404099#M23201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not sure how to do this through VB, but you can look into using Python using the &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/index.html#/ListLayers/00s30000002n000000/" rel="nofollow" target="_blank"&gt;List Layers&lt;/A&gt;&lt;SPAN&gt; function and the &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/index.html#//001200000020000000" rel="nofollow" target="_blank"&gt;Feature Class to Feature Class&lt;/A&gt;&lt;SPAN&gt; tool:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Temp\Project.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] count = 0 for lyr in arcpy.mapping.ListLayers(mxd, "", df):&amp;nbsp; if count &amp;lt; 3: &amp;nbsp; count +=1 &amp;nbsp; name = lyr.name &amp;nbsp; arcpy.FeatureClassToFeatureClass_conversion(lyr, r"C:\Temp", name + ".shp") print "Finished Exporting" del mxd, df, count, name&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2013 22:36:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404099#M23201</guid>
      <dc:creator>JonathanQuinn</dc:creator>
      <dc:date>2013-01-15T22:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Export Multiple Shapefiles from TOC</title>
      <link>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404100#M23202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My main goal here is to take 100s of shapefiles that are in my .mxd from many different sources) and save them into one location. at this time preferable a folder. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2013 22:51:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404100#M23202</guid>
      <dc:creator>CraigMcClain</dc:creator>
      <dc:date>2013-01-15T22:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Export Multiple Shapefiles from TOC</title>
      <link>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404101#M23203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Right.&amp;nbsp; Update the sample I provided to point to the mxd you're looking to work with, update the data frame name if need be, update the value from the if count &amp;lt; 3: line to correspond to the number of layers starting from the top you want to export, and update the output location.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2013 22:54:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404101#M23203</guid>
      <dc:creator>JonathanQuinn</dc:creator>
      <dc:date>2013-01-15T22:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: Export Multiple Shapefiles from TOC</title>
      <link>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404102#M23204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks this works great.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jan 2013 18:49:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404102#M23204</guid>
      <dc:creator>CraigMcClain</dc:creator>
      <dc:date>2013-01-16T18:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: Export Multiple Shapefiles from TOC</title>
      <link>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404103#M23205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what would a python script look like if all of the layers that needed to be exported were rasters? Would it be possible to repost the script so that it reads vertically, on multiple lines? Also, I am confused part of the code: what does the "count=0", "count +=1" and the "name = lyr.name" lines mean?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2017 23:46:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404103#M23205</guid>
      <dc:creator>StephenFortney</dc:creator>
      <dc:date>2017-01-04T23:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: Export Multiple Shapefiles from TOC</title>
      <link>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404104#M23206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"C:\Temp\Project.mxd"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
df &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListDataFrames&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Layers"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
count &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt; 
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; lyr &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; df&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; count &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;3&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; count &lt;SPAN class="operator token"&gt;+=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;FeatureClassToFeatureClass_conversion&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"C:\Temp"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; name &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;".shp"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Finished Exporting"&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;del&lt;/SPAN&gt; mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; df&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; count&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; name‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure why the original comment came out in a single line, but here it is posted correctly. &amp;nbsp;First, you'd still list&amp;nbsp;the layers in the data frame on line 5. &amp;nbsp;You could find which are rasters by following the &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/layer-class.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Layer&lt;/A&gt; documentation. &amp;nbsp;The name = lyr.name is from that documentation as well, basically just getting the name of the layer from the TOC. &amp;nbsp;The original question was how to get the first x layers, so in the example, a variable is set to 0 to act as a counter, then the loop starts through all layers, adding 1 to the counter as it loops through each layer. &amp;nbsp;Once the number of layers gone through is less than 3, continue on to export the feature class. &amp;nbsp;To process rasters, switch the arcpy.FeatureClassToFeatureClass toop with the&amp;nbsp;arcpy.CopyRaster tool or whatever other tool you want to use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;import arcpy, os
mxd = arcpy.mapping.MapDocument(r"C:\Temp\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
for lyr in arcpy.mapping.ListLayers(mxd, "", df):
&amp;nbsp; if lyr.isRaster():
&amp;nbsp;&amp;nbsp;&amp;nbsp; name = lyr.name
&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = os.path.join(r"C:\Temp","{0}.tiff".format(name))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyRaster_management(lyr, outRaster)
print "Finished Exporting"&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So line 4 loops through the layers, line 5 checks if it's of type Raster layer, line 6 gets the name of the layer from the TOC, line 7 uses the os.path.join function to construct the path to the output raster using the format function to create the output name, and line 8 runs the tool.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:25:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404104#M23206</guid>
      <dc:creator>JonathanQuinn</dc:creator>
      <dc:date>2021-12-11T18:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: Export Multiple Shapefiles from TOC</title>
      <link>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404105#M23207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you! your explanation of the original script, as well as the modification of the script to work with rasters are both very helpful. I have run the script on polylines, polygons, and point layers with success.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Jan 2017 20:35:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404105#M23207</guid>
      <dc:creator>StephenFortney</dc:creator>
      <dc:date>2017-01-22T20:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: Export Multiple Shapefiles from TOC</title>
      <link>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404106#M23208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for this script Jonathan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to run it with over 1,000 layers in the TOC. I simply removed the lines regarding the Count but am encountering an error that a specific object already exists. I know it is relatively simple to override this but I am not sure how.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 182 GDBs loaded into the TOC, all with the 7 same feature classes that I need exported in this fashion.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would greatly appreciate your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Dec 2017 16:38:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/export-multiple-shapefiles-from-toc/m-p/404106#M23208</guid>
      <dc:creator>KeitherPerkins2</dc:creator>
      <dc:date>2017-12-07T16:38:12Z</dc:date>
    </item>
  </channel>
</rss>

