blvenetucci

Python Script to Tool in Custom Toolbox

Discussion created by blvenetucci on Jan 31, 2012
Latest reply on Feb 6, 2012 by clockwise
Hi all,

I am trying to create a tool from a script that repairs all broken data sources in an mxd. I have posted the code as follows:
import arcpy, os
PYTHONPATH = "C:\Python26\ArcGIS10.0\lib\ntpath.pyc"
folderpath = arcpy.GetParameterAsText(0)
oldpath = arcpy.GetParameterAsText(1)
newpath = arcpy.GetParameterAsText(2)
print 'running'

i=0
#create a folder within a local folder to store the mxds
folderPath = r""

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() == ".mxd":
           
            mxd = arcpy.mapping.MapDocument(fullpath)
           
            oldpath = ""
            newpath = r""
            #mxd.replaceWorkspaces(oldpath, "SDE_WORKSPACE", newpath, "SDE_WORKSPACE",True)
            print "ok"
            mxd.findAndReplaceWorkspacePaths(oldpath, newpath)
            #mxd.save()
            mxd.save()
      
           
        print '...', basename, extension, "finished"

However, when I run the tool it does not work. Any ideas as to what I have to set my input parameters as or if there is something wrong in my code?

Thanks!

Brittney

Outcomes