ListWorkspaces (arcpy)

サマリ

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

説明

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

構文

ListWorkspaces ({wild_card}, {workspace_type})
パラメータ説明データ タイプ
wild_card

ワイルドカードを使用して、返される結果を絞り込むことができます。ワイルドカードを指定しない場合は、すべての値が返されます。

String
workspace_type

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

  • AccessOnly personal geodatabases will be selected.
  • CoverageOnly coverage workspaces will be selected.
  • FileGDBOnly file geodatabases will be selected.
  • FolderOnly shapefile workspaces will be selected.
  • SDEOnly ArcSDE databases will be selected.
  • AllAll workspaces will be selected. This is the default.

(デフォルト値は次のとおりです All)

String
戻り値
データ タイプ説明
String

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

コードのサンプル

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)

関連トピック

9/14/2013