AnsweredAssumed Answered

Script to Change Drive Letter

Question asked by eric.bregant on Apr 14, 2015
Latest reply on Apr 15, 2015 by GSCUser85

Hey everyone, I was recently informed that my company's IT dept. wants to change the drive letter that all of our GIS files are stored on. We have thousands of .mxds, layer files and .shp files stored on the drive. I have very minor code writing experience so I was looking for some help.

 

Our GIS folder is on the H: drive and we have folders for each client with a "project" sub-folder that contains all the .mxds  a "shapefile" folder that contains all the .shp files an "images" folder and "tables" folder. I attached some images to show the basic structure!

 

The drive letter that my company wants to switch to is F:

 

I have started to mess around with the following python script I found on here.

 

import os

     for dirname, dirnames, filenames in os.walk(r"H:\GIS Something something something"):

          for filename in filenames:

          path = os.path.join(dirname, filename)

          basename, extension = os.path.splitext(path)

          if extension == ".mxd":

               mxd = arcpy.mapping.MapDocument(path)

               mxd.findAndReplaceWorkspacePaths(r"H:", r"F:")

               mxd.save()

               del mxd

 

I know I am missing chunks of code that deal with the shapefile, image and table folders. Just not sure where to put all that stuff.

 

Thanks to anyone that can help me out!

 

-Eric

Outcomes