<?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: Change Data Source to new GDB in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509517#M40026</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Harles,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How does it know which folder the MXDs are in?&amp;nbsp; What if the MXDs are in a different folder than the GDB?&amp;nbsp; Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Dec 2010 13:47:30 GMT</pubDate>
    <dc:creator>StuartBlumberg</dc:creator>
    <dc:date>2010-12-16T13:47:30Z</dc:date>
    <item>
      <title>Change Data Source to new GDB</title>
      <link>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509509#M40018</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;BR /&gt;&lt;SPAN&gt;All I want to do is change the data source of all layers of all MXDs in a single folder from one FGDB to another.&amp;nbsp; For example I want the data sources to be changed from "Project.gdb" to "Project2010.gdb"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried all the python code from the help topics and can't seem to get the right script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Dec 2010 14:30:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509509#M40018</guid>
      <dc:creator>StuartBlumberg</dc:creator>
      <dc:date>2010-12-15T14:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Change Data Source to new GDB</title>
      <link>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509510#M40019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There is a related forum on &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/16892-Change-Data-Source-Using-Python"&gt;changing the data source using python&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is a script offered there from the Resource Center, also note, that these scripts are offered as examples already installed as part of v10 in the toolbox.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Did that referred forum offer you your solution?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Dec 2010 14:55:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509510#M40019</guid>
      <dc:creator>DonovanCameron</dc:creator>
      <dc:date>2010-12-15T14:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: Change Data Source to new GDB</title>
      <link>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509511#M40020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The forum link you provided is for changing the data source from one folder path to another.&amp;nbsp; I need to change from one FGDB to another.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Dec 2010 15:08:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509511#M40020</guid>
      <dc:creator>StuartBlumberg</dc:creator>
      <dc:date>2010-12-15T15:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: Change Data Source to new GDB</title>
      <link>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509512#M40021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; I need to change from one FGDB to another.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am pretty sure you can, the script just needs to be modified to do so.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Look at the help on the syntax for &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s30000004p000000.htm"&gt;Updating and fixing data sources with arcpy.mapping&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Go down to the Usage section and find the header(s):&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG style="color: Sienna;"&gt;Data is migrated from one workspace type to another workspace type&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG style="color: Sienna;"&gt;Individual datasets are moved in and out of feature datasets&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also look at the Known Limitations in regards to these specific processes. They will offer pointers on writing your script with that you can and cannot do currently.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Dec 2010 15:37:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509512#M40021</guid>
      <dc:creator>DonovanCameron</dc:creator>
      <dc:date>2010-12-15T15:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: Change Data Source to new GDB</title>
      <link>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509513#M40022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've gone through those examples multiple times, trying different variations to get it to change the FGDB with no luck.&amp;nbsp; My problem is I don't know Python enough to correctly format the code.&amp;nbsp; Is there code out there specifically for my purpose?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Dec 2010 15:40:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509513#M40022</guid>
      <dc:creator>StuartBlumberg</dc:creator>
      <dc:date>2010-12-15T15:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: Change Data Source to new GDB</title>
      <link>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509514#M40023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can do it with python, but if you just have one mxd to fix, simply right-click on the mxd in ArcCatalog, click "Set Data Source(s)...", then click the "Select All" then the "Replace All" buttons.&amp;nbsp; Finally, type the name of the new FGDB and save the mxd.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Dec 2010 11:33:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509514#M40023</guid>
      <dc:creator>RDHarles</dc:creator>
      <dc:date>2010-12-16T11:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: Change Data Source to new GDB</title>
      <link>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509515#M40024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;rdharles,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I have multiple MXDs in a folder and I need to change them all at once how would I do this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Dec 2010 12:07:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509515#M40024</guid>
      <dc:creator>StuartBlumberg</dc:creator>
      <dc:date>2010-12-16T12:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: Change Data Source to new GDB</title>
      <link>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509516#M40025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try this, worked for me...:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os

# Set current workspace
arcpy.env.workspace = os.getcwd()

# For every mxd in the current directory
for mxd in os.listdir(''):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if mxd.endswith('.mxd'):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Changing paths in "+mxd+"..."
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(mxd)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Note: Back slashes seemed to be required for it to work.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.findAndReplaceWorkspacePaths(r"c:\junk\fgdb\python\b.gdb", r"c:\junk\fgdb\python\a.gdb")&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; mxd.save()
del mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:19:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509516#M40025</guid>
      <dc:creator>RDHarles</dc:creator>
      <dc:date>2021-12-11T22:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Change Data Source to new GDB</title>
      <link>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509517#M40026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Harles,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How does it know which folder the MXDs are in?&amp;nbsp; What if the MXDs are in a different folder than the GDB?&amp;nbsp; Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Dec 2010 13:47:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509517#M40026</guid>
      <dc:creator>StuartBlumberg</dc:creator>
      <dc:date>2010-12-16T13:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Change Data Source to new GDB</title>
      <link>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509518#M40027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;How does it know which folder the MXDs are in?&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;How are you running your scripts? (ArcToolBox, Pythonwin, command line, etc).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;More than likely you just need to set the arcpy.env.workspace to where your .py scripts are.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;e.g. arcpy.env.workspace = "c:/temp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[I run my scripts from a windows command line so the workspace is always my current directory.]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;What if the MXDs are in a different folder than the GDB? &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Shouldn't matter as long as you use the correct replace path:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/00s3/00s30000000n000000.htm"&gt;MapDocument.findAndReplaceWorkspacePaths&lt;/A&gt;&lt;SPAN&gt;(find_workspace_path, replace_workspace_path)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Dec 2010 13:59:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-data-source-to-new-gdb/m-p/509518#M40027</guid>
      <dc:creator>RDHarles</dc:creator>
      <dc:date>2010-12-16T13:59:00Z</dc:date>
    </item>
  </channel>
</rss>

