Changing LYR from absolute to relative path through ArcPy

Discussion created by tmacey on Aug 31, 2010
Latest reply on Jun 5, 2012 by jaygis
I need to change thousands of LYR files to use relative paths instead of absolute.  Following the example in help I got this:

import arcpy, os
folderPath = r"C:\Testing\ArcGIS10_release\paths"
for filename in os.listdir(folderPath):
    fullpath = os.path.join(folderPath, filename)
    if os.path.isfile(fullpath):
        basename, extension = os.path.splitext(fullpath)
        if extension.lower() == ".lyr":
            lyr = arcpy.mapping.Layer(fullpath)
            lyr.findAndReplaceWorkspacePath (r"C:\Testing\ArcGIS10_release\paths", r"\\ Testing\ArcGIS10_release\paths ")
del lyr

The paths are coming out as broken when I move them to the same path but a different directory (D:\Testing\ArcGIS10_release\paths).  I think I need to append the file name on the end of the path for this to work - but am not sure how.

Any help?