<?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 Batch export of mxd to aprx without without data stored in gdb using python in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/batch-export-of-mxd-to-aprx-without-without-data/m-p/1580821#M92521</link>
    <description>&lt;P&gt;Hello ESRI community.&lt;/P&gt;&lt;P&gt;We ar willing to migrate or work from ArcMap to ArcGIS Pro. We have over 200 mxd we need to export to APRX. We are not motivated to do that manualy. We would rather use a python script to do so.&amp;nbsp;&lt;/P&gt;&lt;P&gt;We got this in the web how ever, it doesn't work. My colleague and I are not python user so it's complcated.&lt;/P&gt;&lt;P&gt;Moreover we want that the mxd data not to stored into the gdb of the project but to the shapefile. All the MXD we have, have only 5 common shapefiles data on a specific folder. we want to keep the data sources where they currently are.&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the script we started:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;import arcpy&lt;/DIV&gt;&lt;DIV&gt;import pathlib&lt;/DIV&gt;&lt;DIV&gt;import os&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;ogDir =input('path to mxd folder')&lt;/DIV&gt;&lt;DIV&gt;dirContents = os.listdir(ogDir)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;for folder_path, subfolders, filenames in os.walk(ogDir):&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; for file in filenames:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if file[-4:] == '.mxd':&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; aprx = arcpy.mp.ArcGISProject(r'path to blank.aprx')&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; filePath = pathlib.Path(folder_path) / file&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mxd = file[:-4]&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; aprx.importDocument(filePath)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; aprx.saveACopy(folder_path + '\\' + mxd + '.aprx')&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;after mxd=file[:-4] i have the following comment:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;IndentationError: unexpected indent&lt;/DIV&gt;&lt;DIV&gt;then&lt;/DIV&gt;&lt;DIV&gt;IndentationError: unexpected indent&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; aprx.importDocument(filePath)&lt;BR /&gt;File "&amp;lt;stdin&amp;gt;", line 1&lt;BR /&gt;aprx.importDocument(filePath)&lt;BR /&gt;IndentationError: unexpected indent&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; aprx.saveACopy(folder_path + '\\' + mxd + '.aprx')&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If you have bette script I would take it.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Final question car we run the script here?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaulEmmanuelLeroux_0-1738333929900.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/124436i1C67409213CBE1E9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaulEmmanuelLeroux_0-1738333929900.png" alt="PaulEmmanuelLeroux_0-1738333929900.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 31 Jan 2025 14:32:43 GMT</pubDate>
    <dc:creator>Paul-EmmanuelLeroux</dc:creator>
    <dc:date>2025-01-31T14:32:43Z</dc:date>
    <item>
      <title>Batch export of mxd to aprx without without data stored in gdb using python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/batch-export-of-mxd-to-aprx-without-without-data/m-p/1580821#M92521</link>
      <description>&lt;P&gt;Hello ESRI community.&lt;/P&gt;&lt;P&gt;We ar willing to migrate or work from ArcMap to ArcGIS Pro. We have over 200 mxd we need to export to APRX. We are not motivated to do that manualy. We would rather use a python script to do so.&amp;nbsp;&lt;/P&gt;&lt;P&gt;We got this in the web how ever, it doesn't work. My colleague and I are not python user so it's complcated.&lt;/P&gt;&lt;P&gt;Moreover we want that the mxd data not to stored into the gdb of the project but to the shapefile. All the MXD we have, have only 5 common shapefiles data on a specific folder. we want to keep the data sources where they currently are.&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the script we started:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;import arcpy&lt;/DIV&gt;&lt;DIV&gt;import pathlib&lt;/DIV&gt;&lt;DIV&gt;import os&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;ogDir =input('path to mxd folder')&lt;/DIV&gt;&lt;DIV&gt;dirContents = os.listdir(ogDir)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;for folder_path, subfolders, filenames in os.walk(ogDir):&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; for file in filenames:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if file[-4:] == '.mxd':&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; aprx = arcpy.mp.ArcGISProject(r'path to blank.aprx')&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; filePath = pathlib.Path(folder_path) / file&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mxd = file[:-4]&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; aprx.importDocument(filePath)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; aprx.saveACopy(folder_path + '\\' + mxd + '.aprx')&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;after mxd=file[:-4] i have the following comment:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;IndentationError: unexpected indent&lt;/DIV&gt;&lt;DIV&gt;then&lt;/DIV&gt;&lt;DIV&gt;IndentationError: unexpected indent&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; aprx.importDocument(filePath)&lt;BR /&gt;File "&amp;lt;stdin&amp;gt;", line 1&lt;BR /&gt;aprx.importDocument(filePath)&lt;BR /&gt;IndentationError: unexpected indent&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; aprx.saveACopy(folder_path + '\\' + mxd + '.aprx')&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If you have bette script I would take it.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Final question car we run the script here?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaulEmmanuelLeroux_0-1738333929900.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/124436i1C67409213CBE1E9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaulEmmanuelLeroux_0-1738333929900.png" alt="PaulEmmanuelLeroux_0-1738333929900.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 14:32:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/batch-export-of-mxd-to-aprx-without-without-data/m-p/1580821#M92521</guid>
      <dc:creator>Paul-EmmanuelLeroux</dc:creator>
      <dc:date>2025-01-31T14:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Batch export of mxd to aprx without without data stored in gdb using python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/batch-export-of-mxd-to-aprx-without-without-data/m-p/1580855#M92525</link>
      <description>&lt;P&gt;I don't believe .importDocument() moves or copies data sources.&amp;nbsp; So if your MXD references shapefiles, the imported APRX map will reference the same data sources.&lt;/P&gt;&lt;P&gt;Yes, you can use propy.bat to execute the python script.&lt;/P&gt;&lt;P&gt;As far as the script itself, I would do something like below (not tested though).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

# User input for MXD directory
in_dir = r'C:\Path\To\MXDs'  # Update this path

# Validate if the input directory exists
if not os.path.exists(in_dir):
    print('Error: The specified directory does not exist.')
    exit()

# Path to a blank ArcGIS Pro project (.aprx)
blank_aprx_path = r'C:\Path\To\Blank.aprx'  # Update this path

# Using arcpy.da.Walk to traverse the directory for MXD files
for dirpath, dirnames, filenames in arcpy.da.Walk(in_dir, datatype='Map'):
    for file in filenames:
        if file.lower().endswith('.mxd'):  # Filter only .mxd files
            file_path = os.path.join(dirpath, file)  # Full path to MXD
            mxd_name = os.path.splitext(file)[0]  # Remove .mxd extension

            try:
                # Create a ArcGISProject object from the blank template
                aprx = arcpy.mp.ArcGISProject(blank_aprx_path)

                # Import the MXD document
                aprx.importDocument(file_path)

                # Save a copy of the new APRX in the same folder
                aprx.saveACopy(os.path.join(dirpath, f'{mxd_name}.aprx'))

                print(f'Successfully converted: {file_path}')

            except Exception as e:
                print(f'Error converting {file_path}: {e}')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 15:44:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/batch-export-of-mxd-to-aprx-without-without-data/m-p/1580855#M92525</guid>
      <dc:creator>Marshal</dc:creator>
      <dc:date>2025-01-31T15:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Batch export of mxd to aprx without without data stored in gdb using python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/batch-export-of-mxd-to-aprx-without-without-data/m-p/1582165#M92714</link>
      <description>&lt;P&gt;Hello Marshal,&lt;/P&gt;&lt;P&gt;Thanks you very much the script works well in our test phase.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paul-Emmanuel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paulo&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 10:31:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/batch-export-of-mxd-to-aprx-without-without-data/m-p/1582165#M92714</guid>
      <dc:creator>Paul-EmmanuelLeroux</dc:creator>
      <dc:date>2025-02-05T10:31:27Z</dc:date>
    </item>
  </channel>
</rss>

