let fxNewPaths = (t as table, i as number) =>
let
iActual = "L" & Text.From(i),
iNext = "L" & Text.From(i+1),
AddCol1 = Table.AddColumn(t, "Lx", each try Table.SelectColumns(Table.AddColumn(Table.SelectRows(Folder.Contents(Record.Field(_, iActual)), each [Content] is table)[[Folder Path],[Name]], iNext, each [Folder Path] & [Name]), {iNext}) otherwise null),
Expand = Table.ExpandTableColumn(AddCol1, "Lx", {iNext})
in
Expand,
FPath = Excel.CurrentWorkbook(){[Name="FPath"]}[Content]{0}[Column1],
FirstRow = Table.FromColumns({{FPath}}, {"L0"}),
LiG = List.Generate(() => [FR = FirstRow, i = 0],
each List.NonNullCount( Table.Column([FR], "L"& Text.From([i]))) <> 0,
each [FR = fxNewPaths([FR], [i]), i = [i]+1],
each [FR]),
TBL = List.Last(LiG),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(TBL, {}, "Attribute", "Folder Path"),
#"Removed Columns" = Table.RemoveColumns(#"Unpivoted Columns",{"Attribute"}),
#"Removed Duplicates" = Table.Distinct(#"Removed Columns"),
#"Sorted Rows" = Table.Sort(#"Removed Duplicates",{{"Folder Path", Order.Ascending}})
in
#"Sorted Rows"