1

Fairly new to python, trying to update the data paths for several dozen MXD files to a new computer that doesn't have the "B" drive of the author.

Does the physical\logical data drive have to actually exist on the new computer, for python to reassign using "mxd.findAndReplaceWorkspacePaths" (say if the MXD references a B: drive, do I need to worry that my data is on the F: or C: drive?

I have a fairly simple script, that I keep getting syntax errors on:

import arcpy
mapdoc = arcpy.mapping.MapDocument("CURRENT")

mapdoc.findAndReplaceWorkspacePaths("<the directory you are changing from>" , "<the directory you are changing to>")

mapdoc.save()

del mapdoc

Using: ArcGIS 10.3.1

Pseudo paths look like:

 from directory: "B:\Data_Directory\My Maps & Data\GIS_GDB_Layers\"

 to directory "C:\GIS_GDB_Layers\"

error: Parsing error SyntaxError: invalid syntax (line 1)

I don't have a B:\ drive on my computer- apparently the person who forwarded the data & MXDs did.

3
  • As per the Tour there should be only one question asked per question.
    – PolyGeo
    Commented Dec 30, 2016 at 6:16
  • 1
    Can you provide pseudo paths for the mapdoc.findAndReplaceWorkspacePaths() method, and also the specific error message? Syntax error usually means something syntax wise is incorrect which prevents the script from running.
    – artwork21
    Commented Dec 30, 2016 at 14:29
  • Pseudo paths look like:
    – Ecomapman
    Commented Jan 1, 2017 at 21:11

1 Answer 1

1

It should make no difference whether the from paths exist on your machine.

Try checking what the layer data sources are set to by using this code snippet:

import arcpy
mapdoc = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mapdoc):
    print lyr.dataSource
del mapdoc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.