• You could try the following query.

    select f.Path, f.FolderName, f.FolderSize, d.FileName, d.FileSize

    from @Folders f

    left outer join @Files d on f.Path = d.Path

    group by grouping sets ((f.Path, Foldername, FolderSize), (f.path, d.FileName, d.FileSize))

    order by f.Path, d.filename

    This produces the same result except there are NULLs rather than empty strings