<!-- https://learnsql.cpetoday.com/functions/m/folder-contents -->
# Folder.Contents

Language: Power Query M
Category: Data sources
Syntax: Folder.Contents(path)
Summary: Lists everything in a folder, both files and subfolders, so you can see the folder's structure before you choose what to load.
Returns: A table with one row for each file and each subfolder, including Name, Attributes and Content.
Level: Intermediate
Related: Folder.Files, File.Contents, Excel.Workbook, Csv.Document, Table.SelectRows

## What it does
Folder.Contents lists what is in a folder, and the subfolders as well. Each subfolder appears as a row whose Content is another folder table, so you can move down the tree. Use it when your files are sorted into subfolders by year or entity and you need to pick a branch of the tree. For a simple flat folder, Folder.Files is usually the better choice.

## Syntax and arguments
- `path`: the folder path, as text, such as `"C:\Finance\Archive"`.

## Example
Monthly files are kept in subfolders by year, such as 2025 and 2026. The query finds the 2026 subfolder and then lists the files in it.

```powerquery
let
    Root = Folder.Contents("C:\Finance\Archive"),
    Year2026 = Root{[Name = "2026"]}[Content],
    Files = Table.SelectRows(Year2026, each [Extension] = ".csv")
in
    Files
```

`Root` lists the year folders, `[Name = "2026"]` selects one, and its Content is the table of files inside. The filter then keeps the CSV files.

## Example: a second, different use
Listing every file across all subfolders by combining the Content of each subfolder row, when you need one list rather than a tree.

## Things to watch
- A subfolder row has a Content column holding a table, not binary. Pick the folder by name before you read a file.
- Filter out subfolder rows before you read files, or the read step will fail on them.
- The structure is only as stable as the folders. Renaming a year folder breaks a lookup by name.
- For a single flat folder, Folder.Files is simpler and clearer.

## In business terms
Archives organized by year, entity or period are common in audit and close files. Navigating with Folder.Contents lets the query follow the same structure the team uses to file its work.
