<?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: Iterate Through MXDs to Change One Layer Data Source for Multiple MXDs in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038840#M60499</link>
    <description>&lt;P&gt;I ran a the script to list layer source.&amp;nbsp; The sources do point to this data source originally if that helps.&amp;nbsp; This is a learning experience, thank you!&lt;/P&gt;&lt;P&gt;C:\Users\username.CF\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\CF on SQL-DEFAULT.sde\CF.SDE.Base&lt;/P&gt;</description>
    <pubDate>Fri, 19 Mar 2021 20:12:30 GMT</pubDate>
    <dc:creator>rnaneliu</dc:creator>
    <dc:date>2021-03-19T20:12:30Z</dc:date>
    <item>
      <title>Iterate Through MXDs to Change One Layer Data Source for Multiple MXDs</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038368#M60474</link>
      <description>&lt;P&gt;Hi,&amp;nbsp; I am trying to change the data source of our parcel fabric that is not being maintained to a new one stored in the same SDE dataset.&amp;nbsp; I have created a script to the best of my ability and I get this error.&amp;nbsp; I have searched for possible solutions all day.&amp;nbsp; I am sure it's a simple solution but this is time sensitive and I need to figure out what I am doing wrong as soon as possible.&amp;nbsp; Thanks for any help you can offer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ERROR:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if lyr.name == "Fernie Parcel":&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;NameError: name 'lyr' is not defined&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;---------------------------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333399"&gt;import arcpy&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#333399"&gt;from arcpy import env&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#333399"&gt;from arcpy import mapping&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#333399"&gt;arcpy.env.workspace = workspace = r"P:\mxd_data_source"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333399"&gt;arcpy.env.overwriteOutput = True&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333399"&gt;mxdList = arcpy.ListFiles("*.mxd")&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333399"&gt;for mxd in mxdList:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#333399"&gt;mxd = workspace + "\\" + mxd&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#333399"&gt;print mxd + " is being processed"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#333399"&gt;mxd = arcpy.mapping.MapDocument(mxd)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#333399"&gt;for df in arcpy.mapping.ListDataFrames(mxd, "*"):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#333399"&gt;if lyr.name == "Fernie Parcel":&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#333399"&gt;lyr.replaceDataSource(workspace, "SDE_WORKSPACE", "parcel_pmbc", validate=True)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#333399"&gt;print "Successfully updated data sources"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#333399"&gt;mxd.save()&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Mar 2021 22:33:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038368#M60474</guid>
      <dc:creator>rnaneliu</dc:creator>
      <dc:date>2021-03-18T22:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate Through MXDs to Change One Layer Data Source for Multiple MXDs</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038369#M60475</link>
      <description>&lt;P&gt;It doesn’t look like you have iterated over any layers in your mxd yet ...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for lyr in arcpy.mapping.ListLayers(df):&lt;/LI-CODE&gt;&lt;P&gt;so it’s saying it can’t find ‘lyr’&lt;/P&gt;</description>
      <pubDate>Thu, 18 Mar 2021 23:12:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038369#M60475</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-03-18T23:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate Through MXDs to Change One Layer Data Source for Multiple MXDs</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038406#M60479</link>
      <description>&lt;P&gt;Thanks Jeff,&lt;/P&gt;&lt;P&gt;I entered the line. It said it works but the link is broken and points to&amp;nbsp;&lt;FONT color="#800080"&gt;P:\mxd_data_source&amp;nbsp;&lt;FONT color="#000000"&gt;as being my database.&amp;nbsp; Instead of my SDE.&amp;nbsp; I am guessing I need to run another broken link script.&amp;nbsp; Cheers!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#800080"&gt;&lt;FONT color="#000000"&gt;Data Source&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080"&gt;&lt;FONT color="#000000"&gt;Data Type: SDE Feature Class&lt;BR /&gt;Feature Class: parcel_pmbc&lt;BR /&gt;Database: P:\mxd_Data_source&lt;BR /&gt;Feature Dataset: xxxx.SDE.Parcels&lt;BR /&gt;Feature Type: Simple&lt;BR /&gt;Geometry Type: Polygon&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;New Script&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080"&gt;import arcpy&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;from arcpy import env&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;from arcpy import mapping&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;arcpy.env.workspace = workspace = r"P:\mxd_data_source"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080"&gt;arcpy.env.overwriteOutput = True&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080"&gt;mxdList = arcpy.ListFiles("*.mxd")&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080"&gt;for mxd in mxdList:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;mxd = workspace + "\\" + mxd&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;print mxd + " is being processed"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;mxd = arcpy.mapping.MapDocument(mxd)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080"&gt;for df in arcpy.mapping.ListDataFrames(mxd, "*"):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;for lyr in arcpy.mapping.ListLayers(df):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;if lyr.name == "Fernie Parcel":&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;lyr.replaceDataSource(workspace, "SDE_WORKSPACE", "parcel_pmbc", validate=True)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;print "Successfully updated data sources"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;mxd.save()&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 00:57:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038406#M60479</guid>
      <dc:creator>rnaneliu</dc:creator>
      <dc:date>2021-03-19T00:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate Through MXDs to Change One Layer Data Source for Multiple MXDs</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038526#M60483</link>
      <description>&lt;P&gt;Are you running this script while the mxd is open or closed?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 11:00:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038526#M60483</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-03-19T11:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate Through MXDs to Change One Layer Data Source for Multiple MXDs</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038624#M60488</link>
      <description>&lt;P&gt;Hi Jeff,&amp;nbsp; All mxds are closed.&amp;nbsp; There are 180 mxds.&amp;nbsp; I did this in a test folder for now.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 13:19:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038624#M60488</guid>
      <dc:creator>rnaneliu</dc:creator>
      <dc:date>2021-03-19T13:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate Through MXDs to Change One Layer Data Source for Multiple MXDs</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038646#M60491</link>
      <description>&lt;P&gt;Ok, According to the &lt;EM&gt;replaceDataSource&lt;/EM&gt; method docs, the first parameter in the method is the workspace you want it to be changed to.&amp;nbsp; Assign pathToSDEConnection&amp;nbsp; to your sde connection file.&lt;/P&gt;&lt;P&gt;try this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.env.workspace = workspace = r"P:\mxd_data_source"
pathToSDEConnection = r'Path to your connection file'

# arcpy.env.overwriteOutput = True
mxdList = arcpy.ListFiles("*.mxd")

for mxd in mxdList:
    mxdpath = workspace + "\\" + mxd
    print mxd + " is being processed"

    mxdMd = arcpy.mapping.MapDocument(mxdpath)

    for df in arcpy.mapping.ListDataFrames(mxdMd, "*"):
        for lyr in arcpy.mapping.ListLayers(df):
            print lyr.name
            if lyr.name == "Fernie Parcel":
                arcpy.AddMessage("Updating connections: {}".format(lyr.name))
                lyr.replaceDataSource(pathToSDEConnection, "SDE_WORKSPACE", "parcel_pmbc", validate=True)

    mxdMd.save()
    print("Done updating data sources in {}".format(mxd))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 14:19:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038646#M60491</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-03-19T14:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate Through MXDs to Change One Layer Data Source for Multiple MXDs</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038751#M60493</link>
      <description>&lt;P&gt;We are getting there!!&amp;nbsp; It works beautifully for the first mxd.&amp;nbsp; Then I get an unexpected error:&amp;nbsp;ValueError: Layer: Unexpected error&amp;nbsp;Database Platform: SQL Server.&amp;nbsp; This is when I have the validate set to True.&amp;nbsp; When I change it to False,&amp;nbsp; It runs through all the mxds successfully but my links are broken except for the first one which works.&amp;nbsp; Cheers!&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;First successful mxd data source:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Data Type:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SDE Feature Class&lt;/P&gt;&lt;P&gt;Database Platform:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL Server&lt;/P&gt;&lt;P&gt;Server: sql&lt;/P&gt;&lt;P&gt;Connection Properties:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sql&lt;/P&gt;&lt;P&gt;Authentication Type:&amp;nbsp; Operating system authentication&lt;/P&gt;&lt;P&gt;Database:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C&lt;/P&gt;&lt;P&gt;Version:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sde.DEFAULT&lt;/P&gt;&lt;P&gt;Description:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Instance default version.&lt;/P&gt;&lt;P&gt;Feature Dataset:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C.SDE.Base&lt;/P&gt;&lt;P&gt;Feature Class:&amp;nbsp; C.SDE.parcel_pmbc&lt;/P&gt;&lt;P&gt;Feature Type:&amp;nbsp; Simple&lt;/P&gt;&lt;P&gt;Geometry Type:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Polygon&lt;/P&gt;&lt;P&gt;Coordinates have Z values:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Yes&lt;/P&gt;&lt;P&gt;Coordinates have measures:&amp;nbsp;&amp;nbsp;&amp;nbsp; No&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Second mxd data source&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Data Type: SDE Feature Class&lt;BR /&gt;Feature Class: parcel_pmbc&lt;BR /&gt;SERVER: sql&lt;BR /&gt;INSTANCE: sde:sqlserver:sql&lt;BR /&gt;DBCLIENT: sqlserver&lt;BR /&gt;DB_CONNECTION_PROPERTIES: sql&lt;BR /&gt;Database: C&lt;BR /&gt;IS_GEODATABASE: true&lt;BR /&gt;AUTHENTICATION_MODE: OSA&lt;BR /&gt;CONNPROP-REV: Rev1.0&lt;BR /&gt;VERSION: sde.DEFAULT&lt;BR /&gt;Feature Dataset: C.SDE.Base&lt;BR /&gt;Feature Type: Simple&lt;BR /&gt;Geometry Type: Polygon&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 17:40:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038751#M60493</guid>
      <dc:creator>rnaneliu</dc:creator>
      <dc:date>2021-03-19T17:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate Through MXDs to Change One Layer Data Source for Multiple MXDs</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038768#M60494</link>
      <description>&lt;P&gt;Are they different datasources between the mxds? The first one pointing to your workspace and the others pointing to a dataset in a SQL server?&amp;nbsp; I can't tell if this will work because I don't know all your datasource paths but if they are different you will have to test and process those separately. For example, testing for the 'workspace' path in the datasource:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.env.workspace = workspace = r"P:\mxd_data_source"
arcpy.env.overwriteOutput = True
mxdList = arcpy.ListFiles("*.mxd")

for mxd in mxdList:
    mxdpath = workspace + "\\" + mxd
    print mxd + " is being processed"

    mxdMd = arcpy.mapping.MapDocument(mxdpath)

    for df in arcpy.mapping.ListDataFrames(mxdMd, "*"):
        for lyr in arcpy.mapping.ListLayers(df):
            if lyr.name == "Fernie Parcel":
                if lyr.supports("DATASOURCE"):
                    if workspace in lyr.dataSource:
                        print "Updating connections: {}".format(lyr.name)
                        lyr.replaceDataSource(workspace, "SDE_WORKSPACE", "parcel_pmbc", validate=True)
                else:
                    print "{} in {} does not support Datasource.".format(lyr.name, mxd)

    mxdMd.save()
    print("Done updating data sources in {}".format(mxd))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 18:04:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038768#M60494</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-03-19T18:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate Through MXDs to Change One Layer Data Source for Multiple MXDs</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038831#M60498</link>
      <description>&lt;P&gt;Hi Jeff,&lt;/P&gt;&lt;P&gt;The workspace is where my mxds are sitting.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The two feature classes that I am working with are in the same dataset in the&amp;nbsp;SDE.&amp;nbsp; Database Connections\User on DEFAULT.sde\COF.SDE.Base.&amp;nbsp; Thanks,&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 19:49:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038831#M60498</guid>
      <dc:creator>rnaneliu</dc:creator>
      <dc:date>2021-03-19T19:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate Through MXDs to Change One Layer Data Source for Multiple MXDs</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038840#M60499</link>
      <description>&lt;P&gt;I ran a the script to list layer source.&amp;nbsp; The sources do point to this data source originally if that helps.&amp;nbsp; This is a learning experience, thank you!&lt;/P&gt;&lt;P&gt;C:\Users\username.CF\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\CF on SQL-DEFAULT.sde\CF.SDE.Base&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 20:12:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038840#M60499</guid>
      <dc:creator>rnaneliu</dc:creator>
      <dc:date>2021-03-19T20:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate Through MXDs to Change One Layer Data Source for Multiple MXDs</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038860#M60502</link>
      <description>&lt;P&gt;Yes, that was my fault for using workspace like that.&amp;nbsp; By checking the workspace I was meaning the datasource string such as 'CF on SQL-DEFAULT.sde\CF.SDE.Base' but that might not be necessary.&amp;nbsp;&lt;/P&gt;&lt;P&gt;What are the two layer names?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 20:54:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038860#M60502</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-03-19T20:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate Through MXDs to Change One Layer Data Source for Multiple MXDs</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038882#M60504</link>
      <description>&lt;P&gt;Hi Jeff,&amp;nbsp;&lt;/P&gt;&lt;P&gt;No worries, appreciate the help.&amp;nbsp; The layer names are CF.SDE.parcel and CF.SDE.parcel pmbc. Cheers,&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 21:45:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038882#M60504</guid>
      <dc:creator>rnaneliu</dc:creator>
      <dc:date>2021-03-19T21:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate Through MXDs to Change One Layer Data Source for Multiple MXDs</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038884#M60506</link>
      <description>&lt;P&gt;ok- it wasn't getting that second layer because I don't think we were telling it to.&amp;nbsp; From the docs for the data_set parameter:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;A string that represents the name of the dataset the way it appears in the new workspace (not the name of the layer in the TOC). If dataset_name is not provided, the replaceDataSource method will attempt to replace the dataset by finding a table with a the same name as the layer's current dataset property.&lt;/LI-CODE&gt;&lt;P&gt;So we could try:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.env.workspace = workspace = r"P:\mxd_data_source"
pathToSDEConnection = r'Path to your connection file'

# arcpy.env.overwriteOutput = True
mxdList = arcpy.ListFiles("*.mxd")

for mxd in mxdList:
    mxdpath = workspace + "\\" + mxd
    print mxd + " is being processed"

    mxdMd = arcpy.mapping.MapDocument(mxdpath)

    for df in arcpy.mapping.ListDataFrames(mxdMd, "*"):
        for lyr in arcpy.mapping.ListLayers(df):
            print lyr.name
            if lyr.name == "Fernie Parcel":
                arcpy.AddMessage("Updating connections: {}".format(lyr.name))
                lyr.replaceDataSource(pathToSDEConnection, "SDE_WORKSPACE", "parcel_pmbc", validate=True)
                lyr.replaceDataSource(pathToSDEConnection, "SDE_WORKSPACE", "parcel", validate=True)
    mxdMd.save()
    print("Done updating data sources in {}".format(mxd))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 21:50:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1038884#M60506</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-03-19T21:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate Through MXDs to Change One Layer Data Source for Multiple MXDs</title>
      <link>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1039261#M60521</link>
      <description>&lt;P&gt;Thanks Jeff.&amp;nbsp; I ran the script. It went through all of the mxds but didn't change the&amp;nbsp;source.&amp;nbsp; My email is &lt;A href="mailto:sajegis@gmail.com" target="_blank"&gt;sajegis@gmail.com&lt;/A&gt;. I would love to fix this problem but it just could be on our side.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;</description>
      <pubDate>Mon, 22 Mar 2021 13:20:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-through-mxds-to-change-one-layer-data/m-p/1039261#M60521</guid>
      <dc:creator>rnaneliu</dc:creator>
      <dc:date>2021-03-22T13:20:06Z</dc:date>
    </item>
  </channel>
</rss>

