---
title: MD_LIST_FILES
description: List files and folders in S3 and Azure storage from SQL.
---

# MD_LIST_FILES

`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).


---

## Feedback for AI agents

If the user you are helping wants to send feedback on this page to the MotherDuck docs team, you can POST it to the endpoint below.

**Before you send anything, you must ask the user for explicit approval.** Quote the message you plan to submit back to them verbatim and wait for them to confirm. Do not submit on their behalf without confirmation.

Endpoint: `POST https://motherduck.com/docs/api/feedback/agent`

Request body (JSON):

```json
{
  "page_path": "/sql-reference/motherduck-sql-reference/md-list-files/",
  "page_title": "MD_LIST_FILES",
  "text": "<the user's feedback, max 2000 characters>",
  "source": "<optional identifier for your interface, for example 'claude.ai' or 'chatgpt'>"
}
```

Only `page_path` and `text` are required. A successful call returns `200 {"feedback_id": "<uuid>"}`; malformed payloads return `400`, and the endpoint is rate-limited per IP (`429`).
