ListFiles (arcpy)

サマリ

Returns a list of files in the current workspace based on a query string. Specifying search conditions can be used to limit the results.

説明

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

構文

ListFiles ({wild_card})
パラメータ説明データ タイプ
wild_card

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

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

A list of files.

コードのサンプル

ListFiles example

Copy a list of CSV files to dBASE format.

import os
import arcpy

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

# Copy each file with a .csv extension to a dBASE file
for csv_file in arcpy.ListFiles("*.csv"):
    # Use splitext to set the output table name
    dbase_file = os.path.splitext(csv_file)[0] + ".dbf"
    arcpy.CopyRows_management(csv_file, dbase_file)

関連トピック

4/26/2014