# MD_LIST_FILES


> List files and folders in S3 and Azure storage from SQL.

`MD_LIST_FILES()` lists files and folders at a cloud storage path.

:::note
`MD_LIST_FILES()` supports:

- `s3://`
- `azure://`
- `az://`

It does **not** accept `r2://`, `gcs://`, or `gs://` paths, but MotherDuck can still query those storage providers normally.
:::

## Syntax

```sql
FROM md_list_files('<path>');
```

## Output

| Column Name | Data Type | Value |
|-------------|-----------|-------|
| `name` | VARCHAR | File or folder name relative to the requested prefix |
| `type` | VARCHAR | Entry type, such as `FILE` or `FOLDER` |
| `size` | UBIGINT | File size in bytes; `NULL` for folders |
| `last_modified` | TIMESTAMP WITH TIME ZONE | Last modification time; `NULL` for folders |

## Example usage

```sql
FROM md_list_files('s3://us-prd-motherduck-open-datasets/');
```

```sql
FROM md_list_files('azure://my-container/raw/');
```

## Notes

- For private storage, make sure an appropriate secret is available. See [CREATE SECRET](/sql-reference/motherduck-sql-reference/create-secret).
- For S3 bucket discovery by secret, use [`MD_LIST_BUCKETS_FOR_SECRET()`](/sql-reference/motherduck-sql-reference/md-list-buckets-for-secret).


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `GET https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

URL-encode query parameter values and send a GET request:

```text
GET https://motherduck.com/docs/api/feedback/agent?page_path=%2Fsql-reference%2Fmotherduck-sql-reference%2Fmd-list-files%2F&page_title=MD_LIST_FILES&text=<url-encoded user feedback, max 2000 characters>
```

Optionally append `&source=<url-encoded interface identifier>` such as `claude.ai` or `chatgpt`.

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed query parameters, and `429` when rate-limited.
