<?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: need to know which mxds are pointing to a certain source path... in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/need-to-know-which-mxds-are-pointing-to-a-certain/m-p/45605#M3606</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, thanks for the suggestion to move it to Python.&amp;nbsp; I've never posted to this forum before, so I was unaware.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Jan 2015 17:22:06 GMT</pubDate>
    <dc:creator>KirstenJohnson</dc:creator>
    <dc:date>2015-01-28T17:22:06Z</dc:date>
    <item>
      <title>need to know which mxds are pointing to a certain source path...</title>
      <link>https://community.esri.com/t5/python-questions/need-to-know-which-mxds-are-pointing-to-a-certain/m-p/45603#M3604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello there.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have a vast amount of mxds, and my goal is to search that entire drive and find out which mxds have layers that are referencing a specific source path.&amp;nbsp; Then I would like to know how to replace that specific source path with the new source path.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would presume that this would require a python script.&amp;nbsp; All of the scripts I've found so far require that I know the name of the particular mxd in question.&amp;nbsp; I'm trying to scan all of the mxds in the drive.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Kirsten&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jan 2015 17:08:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-to-know-which-mxds-are-pointing-to-a-certain/m-p/45603#M3604</guid>
      <dc:creator>KirstenJohnson</dc:creator>
      <dc:date>2015-01-28T17:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: need to know which mxds are pointing to a certain source path...</title>
      <link>https://community.esri.com/t5/python-questions/need-to-know-which-mxds-are-pointing-to-a-certain/m-p/45604#M3605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is how to loop through your drive, using Python's os module, to find all the mxds:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="kwd" style="color: #8a4a0b;"&gt;import&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; os

&lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #8a4a0b;"&gt;for&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; root&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #145680;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; dirs&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #145680;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; files &lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #8a4a0b;"&gt;in&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; os&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #145680;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;walk&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #145680;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="str" style="color: #800000;"&gt;'C:/junk'&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #145680;"&gt;):&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;
&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #8a4a0b;"&gt;for&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; file &lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #8a4a0b;"&gt;in&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; files&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #145680;"&gt;:&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #8a4a0b;"&gt;if&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; os&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #145680;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;path&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #145680;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;splitext&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #145680;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;file&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #145680;"&gt;)[&lt;/SPAN&gt;&lt;SPAN class="lit" style="color: #953838;"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #145680;"&gt;]&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #145680;"&gt;==&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #800000;"&gt;'.mxd'&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #145680;"&gt;:&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #8a4a0b;"&gt;print&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #800000;"&gt;'It is an MXD!'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...from &lt;A href="http://gis.stackexchange.com/questions/132006/iterate-through-folders-within-folders/132014?noredirect=1#comment189377_132014" rel="nofollow noopener noreferrer" target="_blank"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:46:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-to-know-which-mxds-are-pointing-to-a-certain/m-p/45604#M3605</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-10T21:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: need to know which mxds are pointing to a certain source path...</title>
      <link>https://community.esri.com/t5/python-questions/need-to-know-which-mxds-are-pointing-to-a-certain/m-p/45605#M3606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, thanks for the suggestion to move it to Python.&amp;nbsp; I've never posted to this forum before, so I was unaware.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jan 2015 17:22:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-to-know-which-mxds-are-pointing-to-a-certain/m-p/45605#M3606</guid>
      <dc:creator>KirstenJohnson</dc:creator>
      <dc:date>2015-01-28T17:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: need to know which mxds are pointing to a certain source path...</title>
      <link>https://community.esri.com/t5/python-questions/need-to-know-which-mxds-are-pointing-to-a-certain/m-p/45606#M3607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for that.&amp;nbsp; So I now how to get a list of mxds, but I need to know which ones have data layers that are pointing to a certain path.&amp;nbsp; Then I need to replace the paths in those mxds with a new path.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jan 2015 17:24:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-to-know-which-mxds-are-pointing-to-a-certain/m-p/45606#M3607</guid>
      <dc:creator>KirstenJohnson</dc:creator>
      <dc:date>2015-01-28T17:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: need to know which mxds are pointing to a certain source path...</title>
      <link>https://community.esri.com/t5/python-questions/need-to-know-which-mxds-are-pointing-to-a-certain/m-p/45607#M3608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Refer to the &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Getting_started_with_arcpy_mapping_tutorial/00s30000006w000000/"&gt;arcpy.mapping help&lt;/A&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jan 2015 17:27:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-to-know-which-mxds-are-pointing-to-a-certain/m-p/45607#M3608</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-01-28T17:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: need to know which mxds are pointing to a certain source path...</title>
      <link>https://community.esri.com/t5/python-questions/need-to-know-which-mxds-are-pointing-to-a-certain/m-p/45608#M3609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;According to the Help you should be able to use arcpy.da.Walk to loop through the mxd files in a folder (and subfolders):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import os

workspace = r"D:\Xander\GeoNet"
walk = arcpy.da.Walk(workspace, datatype="Map")
for dirpath, dirnames, filenames in walk:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxdfile = os.path.join(dirpath, filename)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... but when I tried it didn't give me any result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, you can use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import os
import fnmatch

directory = r"D:\Xander\GeoNet"
pattern = "*.mxd"
for root, dirs, files in os.walk(directory):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in fnmatch.filter(files, pattern):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxdfile = os.path.join(root, filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "mxd file: {0}".format(mxdfile)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(mxdfile)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dfs = arcpy.mapping.ListDataFrames(mxd)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for df in dfs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print " - data frame: {0}".format(df.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for lyr in arcpy.mapping.ListLayers(mxd, data_frame=df):
&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;&amp;nbsp; print "&amp;nbsp;&amp;nbsp; - layer name: {0}".format(lyr.name)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... to loop through the mxd's, the data frames and layers within the dataframes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To update any datasource I recommend you to read this page of the Help: &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#/Updating_and_fixing_data_sources_with_arcpy_mapping/00s30000004p000000/" title="http://resources.arcgis.com/en/help/main/10.2/index.html#/Updating_and_fixing_data_sources_with_arcpy_mapping/00s30000004p000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;ArcGIS Help (10.2, 10.2.1, and 10.2.2)&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:46:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-to-know-which-mxds-are-pointing-to-a-certain/m-p/45608#M3609</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-10T21:46:32Z</dc:date>
    </item>
  </channel>
</rss>

