Mapping Replace Workspaces issue

Discussion created by ben_sloboda on Aug 9, 2012
Latest reply on Aug 12, 2012 by brucejr312
I have the following code:

import arcpy
fileFolder = r"G:\ProjectF\GIS\Projects\INRMP\Burlington\GIS_Maps"
oldSpace = r"G:\ProjectF\GIS\Projects\INRMP\Burlington\GIS_Data\Burlington GIS\ANG_Burlington\ANG_Burlington_CIP.mdb\cadastre\installation_area"
newSpace = r"G:\ProjectF\GIS\Projects\INRMP\Burlington\GIS_Data\Burlington GIS\VTANG_Boundary.shp"

for element in fileFolder:
    fileType = element[-4:]
    if fileType == ".mxd":
        mxd = arcpy.mapping.MapDocument(element)

The premise is simple.  Iterate through a number of mxd files in the fileFolder location and change the source for one of the layers.  There are other files, so to prevent the silly "Invalid MXD filename" error, I added an if clause which checks for the fileType variable.  This variable is set to the last four characters of the file, so it would know if the file is an mxd.  If the fileType is an mxd, it replaces the old .mdb source with the new .shp source.  The problem is this: the script runs with no errors, but does not actually replace the source file in the corresponding mxds.


-Ben S.