ListFiles

概要

Returns a list of files in the current workspace.

ディスカッション

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

構文

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

Limits the results returned. If a value is not specified, all values are returned. The wildcard is not case sensitive.

SymbolDescriptionExample

*

Represents zero or more characters.

Te* finds Tennessee and Texas.

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)

関連トピック