<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Script to Change Drive Letter in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/script-to-change-drive-letter/m-p/525033#M41150</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are on the right track there with "findAndReplace...."&lt;/P&gt;&lt;P&gt;As you have probably seen the examples here :&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#/Updating_and_fixing_data_sources_with_arcpy_mapping/00s30000004p000000/"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#/Updating_and_fixing_data_sources_with_arcpy_mapping/00s30000004p000000/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;But for the future you should maybe consider using relative pathnames from the mxd to the data.&lt;/P&gt;&lt;P&gt;Found in the map doc properties page.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="MapDocProperties_RelativePaths.jpg" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/85318_MapDocProperties_RelativePaths.jpg" style="height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Apr 2015 08:18:31 GMT</pubDate>
    <dc:creator>NeilAyres</dc:creator>
    <dc:date>2015-04-15T08:18:31Z</dc:date>
    <item>
      <title>Script to Change Drive Letter</title>
      <link>https://community.esri.com/t5/python-questions/script-to-change-drive-letter/m-p/525032#M41149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;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.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;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&amp;nbsp; a "shapefile" folder that contains all the .shp files an "images" folder and "tables" folder. I attached some images to show the basic structure!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;The drive letter that my company wants to switch to is F:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;I have started to mess around with the following python script I found on here.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;import os&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for dirname, dirnames, filenames in os.walk(r"H:\GIS Something something something"):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; path = os.path.join(dirname, filename)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; basename, extension = os.path.splitext(path)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if extension == ".mxd":&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(path)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.findAndReplaceWorkspacePaths(r"H:", r"F:")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.save()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del mxd&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks to anyone that can help me out!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Eric&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 22:37:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-to-change-drive-letter/m-p/525032#M41149</guid>
      <dc:creator>EricBregant</dc:creator>
      <dc:date>2015-04-14T22:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: Script to Change Drive Letter</title>
      <link>https://community.esri.com/t5/python-questions/script-to-change-drive-letter/m-p/525033#M41150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are on the right track there with "findAndReplace...."&lt;/P&gt;&lt;P&gt;As you have probably seen the examples here :&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#/Updating_and_fixing_data_sources_with_arcpy_mapping/00s30000004p000000/"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#/Updating_and_fixing_data_sources_with_arcpy_mapping/00s30000004p000000/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;But for the future you should maybe consider using relative pathnames from the mxd to the data.&lt;/P&gt;&lt;P&gt;Found in the map doc properties page.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="MapDocProperties_RelativePaths.jpg" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/85318_MapDocProperties_RelativePaths.jpg" style="height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Apr 2015 08:18:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-to-change-drive-letter/m-p/525033#M41150</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2015-04-15T08:18:31Z</dc:date>
    </item>
  </channel>
</rss>

