ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

ListWorkspaces

  • Summary
  • Discussion
  • Syntax
  • Code sample

Summary

Lists all of the workspaces within the set workspace. Search conditions can be specified for the workspace name and workspace type to limit the list that is returned.

Discussion

The workspace environment must be set first before using several of the List functions, including ListDatasets, ListFeatureClasses, ListFiles, ListRasters, ListTables, and ListWorkspaces.

Syntax

ListWorkspaces ({wild_card}, {workspace_type})
ParameterExplanationData Type
wild_card

The wild_card limits the results returned. If no wild_card is specified, all values are returned.

String
workspace_type

The workspace type to limit the results returned by the wild card argument. There are six possible workspace types:

  • Access —Only personal geodatabases will be selected.
  • Coverage —Only coverage workspaces will be selected.
  • FileGDB —Only file geodatabases will be selected.
  • Folder —Only shapefile workspaces will be selected.
  • SDE —Only enterprise databases will be selected.
  • All —All workspaces will be selected. This is the default.

(The default value is All)

String

Return Value

Data TypeExplanation
String

The list containing workspace names is returned from the function, limited by the wild card and workspace type arguments.

Code sample

ListWorkspaces example

Compact all File Geodatabases in workspace.

import arcpy

arcpy.env.workspace = "c:/data"

# List all file geodatabases in the current workspace
workspaces = arcpy.ListWorkspaces("*", "FileGDB")

for workspace in workspaces:
    # Compact each geodatabase
    arcpy.Compact_management(workspace)

Related topics

  • Create lists of data
  • Walk

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2019 Esri. | Privacy | Legal