Skip to content

Instantly share code, notes, and snippets.

@pdbartsch
Last active March 15, 2019 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdbartsch/9c09aefe399124a80809c4d90244fc45 to your computer and use it in GitHub Desktop.
Save pdbartsch/9c09aefe399124a80809c4d90244fc45 to your computer and use it in GitHub Desktop.
Simple example of updating a single mxd file that has missing sources when data is moved to a new folder. For more information see: http://desktop.arcgis.com/en/arcmap/10.6/analyze/arcpy-mapping/updatingandfixingdatasources.htm
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Projects\arc_examples\broken_sources_example.mxd")
original_directory = r"C:\Projects\arc_examples"
new_directory = r"C:\Projects\arc_examples\data_moved_to_this_folder"
mxd.findAndReplaceWorkspacePaths(original_directory, new_directory)
mxd.saveACopy(r"C:\Projects\arc_examples\data_moved_to_this_folder\new_map.mxd")
del mxd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment