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


---

## Docs feedback

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

Payload:

```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'>"
}
```

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