Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Python script for mass find and replace of workspace path?

$
0
0
Hi folks,

As our research group has run out of space on a network drive, our IT department just moved all of our folders/data to a new network drive. However, in doing this all of the folder structures for the data locations have changed. As a result, none of our project files (e.g., .mxd) are functioning. As we have ~150-200 .mxd project files does anyone know if there is a piece of code which can automatically work through all of the ArcGIS related folders and find and replace the mapped network drive info or the folder structure.

I found this piece of code, but this only works for a single file. What I would like to be able to do is a batch process to look through all folders/subfolders/files and find and replace the workspace path (Note: we are working with ArcGIS 10.1).

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
mxd.findAndReplaceWorkspacePaths(r"C:\Project\Data", r"D:\Project\Data")
mxd.saveACopy(r"D:\Project\Project.mxd")
del mxd

Thanks.

Viewing all articles
Browse latest Browse all 2485

Trending Articles