<?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: I have a ArcView map with a few of layers, and I want to export them to one locat in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/i-have-a-arcview-map-with-a-few-of-layers-and-i/m-p/314115#M24411</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;but if I just want to export the data sources of these existing layers in my map to the new location instead of all files in the old location. Which function I can use? Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Aug 2011 14:34:56 GMT</pubDate>
    <dc:creator>qiangxue</dc:creator>
    <dc:date>2011-08-16T14:34:56Z</dc:date>
    <item>
      <title>I have a ArcView map with a few of layers, and I want to export them to one location?</title>
      <link>https://community.esri.com/t5/python-questions/i-have-a-arcview-map-with-a-few-of-layers-and-i/m-p/314112#M24408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;the datasources of these layers are different, some of them are shapefile, and some are from geodatabase, Now I want to write a python script, and export all data into another new geodatabase, and relink them with map layers, and save a new copy. How can I do this? Could anybody give me a hint? I am new to python, and not very familiar with python functions. I did not find the functions I want. Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Aug 2011 15:35:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-have-a-arcview-map-with-a-few-of-layers-and-i/m-p/314112#M24408</guid>
      <dc:creator>qiangxue</dc:creator>
      <dc:date>2011-08-15T15:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: I have a ArcView map with a few of layers, and I want to export them to one locat</title>
      <link>https://community.esri.com/t5/python-questions/i-have-a-arcview-map-with-a-few-of-layers-and-i/m-p/314113#M24409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If all your shapefiles reside in one folder, and your feature classes within a single geodatabase you can use the 'arcpy.ListFeatureClasses' function to list all shapefiles and feature classes then append them to a list.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Next, you can use the 'arcpy.FeatureClassToGeodatabase_conversion' function to convert the shapefiles/feature classes to a new geodatabase.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Finally, you can run the 'replaceWorkspaces' and 'replaceDataSource' methods to remap the datasources and save it as a new MXD.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
from arcpy import env
from arcpy import mapping


folder = r"C:\temp\python"
env.workspace = folder

fcList = []

lstFCs = arcpy.ListFeatureClasses("*")
for fc in lstFCs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcList.append(os.path.join(folder + "\\" + fc))

database = r"C:\temp\python\test.gdb"
env.workspace = database

lstFCs = arcpy.ListFeatureClasses("*")
for fc in lstFCs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcList.append(database + "\\" + fc)

for fc in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print fc
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureClassToGeodatabase_conversion(fc, r"C:\temp\test2.gdb")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Successfully converted"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 

mxd = mapping.MapDocument(r"C:\temp\python\test.mxd")
mxd.replaceWorkspaces(r"C:\Temp\Python", "SHAPEFILE_WORKSPACE", r"C:\Temp\test2.gdb", "FILEGDB_WORKSPACE")
mxd.findAndReplaceWorkspacePaths(r"C:\temp\python\test.gdb", r"C:\temp\test2.gdb")
mxd.saveACopy(r"C:\Temp\Project2.mxd")
print "Save Successful"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If your data resides in multiple folders/geodatabase I would recommend looking into the &lt;/SPAN&gt;&lt;A href="http://docs.python.org/library/os.path.html" rel="nofollow noopener noreferrer" target="_blank"&gt;os.walk&lt;/A&gt;&lt;SPAN&gt; function.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:58:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-have-a-arcview-map-with-a-few-of-layers-and-i/m-p/314113#M24409</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T14:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: I have a ArcView map with a few of layers, and I want to export them to one locat</title>
      <link>https://community.esri.com/t5/python-questions/i-have-a-arcview-map-with-a-few-of-layers-and-i/m-p/314114#M24410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;thank you very much. I will try it later.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Aug 2011 19:23:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-have-a-arcview-map-with-a-few-of-layers-and-i/m-p/314114#M24410</guid>
      <dc:creator>qiangxue</dc:creator>
      <dc:date>2011-08-15T19:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: I have a ArcView map with a few of layers, and I want to export them to one locat</title>
      <link>https://community.esri.com/t5/python-questions/i-have-a-arcview-map-with-a-few-of-layers-and-i/m-p/314115#M24411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;but if I just want to export the data sources of these existing layers in my map to the new location instead of all files in the old location. Which function I can use? Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Aug 2011 14:34:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-have-a-arcview-map-with-a-few-of-layers-and-i/m-p/314115#M24411</guid>
      <dc:creator>qiangxue</dc:creator>
      <dc:date>2011-08-16T14:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: I have a ArcView map with a few of layers, and I want to export them to one locat</title>
      <link>https://community.esri.com/t5/python-questions/i-have-a-arcview-map-with-a-few-of-layers-and-i/m-p/314116#M24412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can use the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s300000008000000.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;arcpy.mapping.ListLayers&lt;/A&gt;&lt;SPAN&gt; function to access the dataSource property.&amp;nbsp; Next you can append this to a list, convert the layers to the new geodatabase, and update the MXD.&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
from arcpy import mapping

env.workspace = r"C:\temp\python"
 
list = []

mxd = mapping.MapDocument(r"C:\temp\python\test.mxd")
for df in mapping.ListDataFrames(mxd, "*"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for layers in mapping.ListLayers(mxd, "*", df):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list.append(layers.dataSource)

for n in list:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureClassToGeodatabase_conversion(n, r"C:\temp\Test2.gdb")

mxd.replaceWorkspaces(r"C:\Temp\Python", "SHAPEFILE_WORKSPACE", r"C:\Temp\test2.gdb", "FILEGDB_WORKSPACE")
mxd.findAndReplaceWorkspacePaths(r"C:\temp\python\test.gdb", r"C:\temp\test2.gdb")
# mxd.replaceWorkspaces(r"C:\temp\python\test.gdb", "FILEGDB_WORKSPACE", r"C:\temp\python\test.gdb", "FILEGDB_WORKSPACE")
mxd.saveACopy(r"C:\Temp\Project2.mxd")
print "Save Successful"&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:58:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-have-a-arcview-map-with-a-few-of-layers-and-i/m-p/314116#M24412</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T14:58:41Z</dc:date>
    </item>
  </channel>
</rss>

