<?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: Changing Data Source for numerous .MXD's in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329855#M3514</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I haven't tried it yet but I guess what I'm trying to do is change the dataset for a layer but do it for every MXD's. Does that make sense. Maybe you already knew that...&lt;BR /&gt;&lt;BR /&gt;Either way I'm looking at your code.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thats what the code is designed to do.&amp;nbsp; The only changes that need to be made are setting the workspace and the workspace path for the new dataset for your layers.&amp;nbsp; It makes a list of all mxds in the workspace, then goes in and changes the workspace paths for all layers in the map document to the workspace path of your new dataset.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Jul 2014 18:33:54 GMT</pubDate>
    <dc:creator>IanMurray</dc:creator>
    <dc:date>2014-07-03T18:33:54Z</dc:date>
    <item>
      <title>Changing Data Source for numerous .MXD's</title>
      <link>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329847#M3506</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;I have 92 different Map Documents that all have the same two layers. I would like to update these 2 layers with a different data source and do this for all 92 Map Documents uniformly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any thoughts on how to go about this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2014 15:34:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329847#M3506</guid>
      <dc:creator>ReubenArvin</dc:creator>
      <dc:date>2014-07-02T15:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Source for numerous .MXD's</title>
      <link>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329848#M3507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This can be done fairly easily using python and the arcpy.mapping module.&amp;nbsp; For the layers, there is a method to replace the data source with a new file path, or can be done for the entire map document, say if the data sources for all layers have changed folders or something similar.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Check out this &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00s30000004p000000" rel="nofollow" target="_blank"&gt;link&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2014 15:59:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329848#M3507</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2014-07-02T15:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Source for numerous .MXD's</title>
      <link>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329849#M3508</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I figured it was too difficult just didn't know the module to use. I will check it out&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the help&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2014 16:07:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329849#M3508</guid>
      <dc:creator>ReubenArvin</dc:creator>
      <dc:date>2014-07-02T16:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Source for numerous .MXD's</title>
      <link>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329850#M3509</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That link was helpful especially the findAndReplaceWorkspacePaths, except the example was for 1 Map Document. I have about 92 that I would like to do it for.&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, 02 Jul 2014 16:18:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329850#M3509</guid>
      <dc:creator>ReubenArvin</dc:creator>
      <dc:date>2014-07-02T16:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Source for numerous .MXD's</title>
      <link>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329851#M3510</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If your maps are in the same folder, then there are easy ways to iterate through all your map documents in a folder.&amp;nbsp; If you set your workspace to the folder they are in, then use the arcpy.ListFiles("*.mxd"), you will make a list of all the map documents in the folder.&amp;nbsp; You can then loop through them and put in the code for findandreplaceworkspace.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you have multiple workspaces, you can loop through workspaces as well with ListWorkspaces.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Check out this &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018v0000000v000000"&gt;link&lt;/A&gt;&lt;SPAN&gt; for help with ListFiles, there is also a link to ListWorkspaces in there.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you have any further questions about this, feel free to ask.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2014 17:49:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329851#M3510</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2014-07-02T17:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Source for numerous .MXD's</title>
      <link>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329852#M3511</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It makes sense as far as the process but I'm not sure how to write the code exactly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you write an sample code to get me started?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Setting workspace for the folder that contains all the MXDs&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Finding and replacing the same layer in each MXD with an updated layer (setting data source to a different shapefile and in all the MXDs)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If that makes sense.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2014 18:29:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329852#M3511</guid>
      <dc:creator>ReubenArvin</dc:creator>
      <dc:date>2014-07-02T18:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Source for numerous .MXD's</title>
      <link>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329853#M3512</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;sure thing&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
#Importing Modules
import arcpy
from arcpy import env

#Put file path for the folder containing mxds, where I have my sample file path
env.workspace = r"C:\Test\MXDfolder"

#Put file path for the folder, gdb, feature dataset, or sde connection containing the files your map layers will be referencing here, where I have my sample file path
replace_workspace_path&amp;nbsp; = r"C:\Test\NewWorkspace"

#Looping through all filepaths in our workspace, make a map document object out of them, then replace their workspace path
for file in arcpy.ListFiles("*.mxd"):
&amp;nbsp; mxd = arcpy.mapping.MapDocument(file)
&amp;nbsp; mxd.findAndReplaceWorkspacePaths(" " , replace_workspace_path)
&amp;nbsp; mxd.save()

del file; del mxd

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So the script makes a list of the filepaths for each mxd, then loops through them, creates a python map document object, which we then call the findandReplaceWorkspacePaths method on to replace the workspace path for all layers in the map documents.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I haven't tested this on anything, and there could be a few errors to debug, but it should be enough to get started.&amp;nbsp; Always feel free to search the arcgis help for any method that you have questions about.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:37:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329853#M3512</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2021-12-11T15:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Source for numerous .MXD's</title>
      <link>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329854#M3513</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I haven't tried it yet but I guess what I'm trying to do is change the dataset for a layer but do it for every MXD's. Does that make sense. Maybe you already knew that...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Either way I'm looking at your code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 13:56:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329854#M3513</guid>
      <dc:creator>ReubenArvin</dc:creator>
      <dc:date>2014-07-03T13:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Data Source for numerous .MXD's</title>
      <link>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329855#M3514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I haven't tried it yet but I guess what I'm trying to do is change the dataset for a layer but do it for every MXD's. Does that make sense. Maybe you already knew that...&lt;BR /&gt;&lt;BR /&gt;Either way I'm looking at your code.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thats what the code is designed to do.&amp;nbsp; The only changes that need to be made are setting the workspace and the workspace path for the new dataset for your layers.&amp;nbsp; It makes a list of all mxds in the workspace, then goes in and changes the workspace paths for all layers in the map document to the workspace path of your new dataset.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 18:33:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/changing-data-source-for-numerous-mxd-s/m-p/329855#M3514</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2014-07-03T18:33:54Z</dc:date>
    </item>
  </channel>
</rss>

