<?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: How to fix broken link inside mxd with script? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707619#M54838</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am also eagerly awaiting a response to this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I often have to move .mxds between my HDD and a shared drive.&amp;nbsp; This one issue is the only impedance to that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 May 2012 13:24:15 GMT</pubDate>
    <dc:creator>KorySteele</dc:creator>
    <dc:date>2012-05-08T13:24:15Z</dc:date>
    <item>
      <title>How to fix broken link inside mxd with script?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707618#M54837</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;Is there a way to fix broken link inside mxd using a script?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;We have old mxd with many layers (200 shapefiles)&amp;nbsp; and we decided to rename the shapefiles using our naming standard and then move them to ArcSDE BUT the relink job is painful. Is there a way in arcpy.mapping scripting?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried some tool from ESRI for fixing broken link but it is still painful. I need to find a script which will do the below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Replace the old path of the layer (ex: C:\Test.shp) to the new path&amp;nbsp; (ex: SDE.Blocks) inside the old mxd.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Haifa&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2012 11:00:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707618#M54837</guid>
      <dc:creator>haifaAl_Yazeedi</dc:creator>
      <dc:date>2012-05-08T11:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix broken link inside mxd with script?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707619#M54838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am also eagerly awaiting a response to this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I often have to move .mxds between my HDD and a shared drive.&amp;nbsp; This one issue is the only impedance to that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2012 13:24:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707619#M54838</guid>
      <dc:creator>KorySteele</dc:creator>
      <dc:date>2012-05-08T13:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix broken link inside mxd with script?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707620#M54839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can use arcpy.mapping to change the data source paths within an MXD.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
mxd.findAndReplaceWorkspacePaths(r"C:\Project\Data", r"C:\Project\Data2")
mxd.saveACopy(r"C:\Project\Project2.mxd")
del mxd&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s30000004p000000" rel="nofollow noopener noreferrer" target="_blank"&gt;Updating and fixing data sources with arcpy.mapping &lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:43:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707620#M54839</guid>
      <dc:creator>TimothyHales</dc:creator>
      <dc:date>2021-12-12T05:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix broken link inside mxd with script?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707621#M54840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;halyazeedi:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think you would need to modify the script from thales007 to have the destination path be a connection to SDE that you have saved on your computer with ArcCatalog.&amp;nbsp; The third line with findAndReplaceWorkspacePaths is a composite of the 1st two lines (that have been commented out) where the source is the current shapefile and the destination is the SDE geodatabase.&amp;nbsp; You might have some issues with field types in the transition from shapefiles to SDE that you would need to work through.&amp;nbsp; You would also need to ensure that you have read access to all the associated feature classes in SDE from the SDE connection that you are using.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r"C:\Project\Project_default.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'mxd.findAndReplaceWorkspacePaths(r"C:\Project\Data", r"C:\Project\Data2")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'mxd.findAndReplaceWorkspacePaths(r"C:\Project\Connection to Default.sde", r"C:\Project\Connection to Version1.sde")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd.findAndReplaceWorkspacePaths(r"C:\Project\Data", r"C:\Project\Connection to Version1.sde")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd.saveACopy(r"C:\Project\Project_V1.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del mxd&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2012 16:41:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707621#M54840</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-05-08T16:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix broken link inside mxd with script?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707622#M54841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you all for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is two issue here first one is the path is changed from shape file to sde and the second issue is the shape files name is changed also..when we imported the shape file into sde we renamed it (ex: test.shp renamed to sde.Blocks).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there way tyo fix both issue using a script?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Haifa&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 May 2012 04:32:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707622#M54841</guid>
      <dc:creator>haifaAl_Yazeedi</dc:creator>
      <dc:date>2012-05-15T04:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix broken link inside mxd with script?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707623#M54842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Layer.replaceDataSource is the method you are looking for.&amp;nbsp; I believe this script would be more complex as you will need to map the old datasource to the new datasource.&amp;nbsp; I have done this by calling a def function where it looks for a specific input layer name and that is mapped to the new layer name with its new parameters.&amp;nbsp; In your case this def could get pretty big as you say you have 200 shapefiles in your mxd(s) that need to be linked to new SDE layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The reference from thales007 has the link to this documentation.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 May 2012 11:33:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707623#M54842</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-05-15T11:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix broken link inside mxd with script?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707624#M54843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know it's an old post but , I was wondering if there is a way to use this script if my shapefiles are in two different documents?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2016 13:34:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707624#M54843</guid>
      <dc:creator>AntoineCantin</dc:creator>
      <dc:date>2016-02-08T13:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix broken link inside mxd with script?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707625#M54844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes you would have to run the script on each mxd that has the broken link in it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2016 13:40:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707625#M54844</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2016-02-08T13:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix broken link inside mxd with script?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707626#M54845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;fwiw, I have an addin (works with 10.2.x/10.3.x) that can look at all the mxd in a folder (and subfolders), provide a report of all broken links and allow you to update a .csv file and then fix most (if not all) of the broken links).&amp;nbsp; Always do a test on a copy first...but, in case you are interested&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migration-blogpost/55043"&gt;Python addin for data inventory and “broken-link” repair.&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not perfect, and may not be work the effort for just two mxd docs...but if yo have a lot, or if machines/paths change, may be worth it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2016 17:16:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707626#M54845</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-02-08T17:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix broken link inside mxd with script?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707627#M54846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'll give it a try, thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2016 18:30:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-fix-broken-link-inside-mxd-with-script/m-p/707627#M54846</guid>
      <dc:creator>AntoineCantin</dc:creator>
      <dc:date>2016-02-08T18:30:48Z</dc:date>
    </item>
  </channel>
</rss>

