Extracts the contents of a package to a specified folder. The output folder will be updated with the extracted contents of the input package.
Supported package types include:
- Geoprocessing Packages (.gpk)
- Layer Packages (.lpk)
- Map Packages (.mpk)
- Locator Packages (.gcpk)
- Tile Packages (.tpk)
The output folder can be a new folder or an existing folder. When extracting to an existing folder, the contents of the package will be appended to existing files and folders. If the output folder already contains the extracted contents of the package, the existing contents will be overwritten.
Packages with attachments will have their attached files unpacked to the commondata\userdata\ subfolder in the Output Folder. Typically the files inside a package are supporting files, like a .pdf, .docx or an image. You will need to navigate to the extracted directory in Windows Explorer to open these files.
ExtractPackage_management (in_package, output_folder)
The input package that will be extracted.
The output folder to contain the contents of the package.
ExtractPackage example 1 (Python window)
The following Python window script demonstrates how to use the ExtractPackage tool.
arcpy.env.workspace = "C:/arcgis/ArcTutor/Getting_Started/Greenvalley" arcpy.ExtractPackage_management('WaterUsePackage.lpk', 'C:/My_Data/Packages/WaterUse_unpacked')
ExtractPackage example 2 (stand-alone script)
Find all Geoprocesssing Packages within a specified folder and use the ExtractPackage tool to extract contents to specified folder.
# Name: ExtractPackage.py # Description: Find Geoprocesssing Packages within a specified folder and extract contents. import arcpy import os arcpy.env.overwriteOutput = True # set folder that contains packages to extract arcpy.env.workspace = "C:/geoprocessing/gpks" wrksp = arcpy.env.workspace for gpk in arcpy.ListFiles("*.gpk"): print("Extracting... " + gpk) arcpy.ExtractPackage_management(gpk, os.path.splitext(gpk)) print("done")
- ArcGIS Desktop Basic: Yes
- ArcGIS Desktop Standard: Yes
- ArcGIS Desktop Advanced: Yes