OpenBI Docs Buy

Folder.Files

Every file in a folder and in the folders below it, a row each, with its bytes in Content.

Group: Files and documents. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Folder.Files(path as text, optional options as nullable record) as table
ParameterTypeDescription
pathtextThe folder's path.
optionsnullable record
optional
Accepted as Power Query writes it; none is read.

Returns

table. Content (the file's bytes), Name, Extension, three dates (Date accessed, Date modified, Date created), Attributes (a record) and Folder Path.

Remarks

  • The folder's own files come first, then each subfolder's, deeper and deeper; folders themselves are not rows. Names are in the order Windows lists them (NTFS's), on every platform.
  • Folder Path is the file's folder ending in its separator; Extension is the part from the name's last dot, with the dot (".csv"), empty when there is none.
  • Attributes holds twenty fields: Content Type, Kind ("CSV File", "Excel File" ...), Size, ReadOnly, Hidden and the other flags of the file system. The dates are local datetimes.
  • To combine files of one layout, filter the rows (on Extension or Name), then read each Content with Csv.Document, Excel.Workbook or Parquet.Document and Table.Combine the tables.

Examples

The files below a folder

The folder holds two monthly files and an archive folder with one more.

Folder.Files("C:\Data\orders")[[Name], [Extension], [Folder Path]]
NameExtensionFolder Path
2026-01.csv.csvC:\Data\orders\
2026-02.csv.csvC:\Data\orders\
2025-12.csv.csvC:\Data\orders\archive\

Every month's orders in one table

let
    Files = Folder.Files("C:\Data\orders"),
    Csv = Table.SelectRows(Files, each [Extension] = ".csv"),
    Tables = List.Transform(Csv[Content], each Table.PromoteHeaders(Csv.Document(_), [PromoteAllScalars = true]))
in
    Table.Combine(Tables)
OrderIdShopProductAmount
1001OsloChair120
1002BergenDesk250
1003OsloLamp45
1004TrondheimChair120
998BergenLamp45

The values are text, as Csv.Document reads them; a Changed Type step follows in a real query.

Folder.Contents, Csv.Document, Table.Combine, File.Contents, Table.SelectRows.

Last updated · OpenBI Studio 0.3.79