I realize this question asked for file size analysis using CMD line
. But if you are open to using PowerQuery (Excel add-in, versions 2010+)
then you can create some pretty compelling file size analysis.
The script below can be pasted into a Blank Query; The only thing you'll need to do is add a parameter named "paramRootFolderSearch" then add your value, such as "C:\Users\bl0040\Dropbox\". I used this as a guide: MSSQLTips: Retrieve file sizes from the file system using Power Query.
This query provided the data for me to create a pivot table ([Folder Root]> [Folder Parent (1-2)], [Name]
), and I was able to identify a few files that I could deleted which cleared up a lot of space in my directory.
Here is the M script for PowerQuery:
let
// Parmameters:
valueRootFolderSearch = paramRootFolderSearch,
lenRootFolderSearch = Text.Length(paramRootFolderSearch),
//
Source = Folder.Files(paramRootFolderSearch),
#"Removed Other Columns" = Table.RenameColumns(
Table.SelectColumns(Source,{"Name", "Folder Path", "Attributes"})
,{{"Folder Path", "Folder Path Full"}}),
#"Expanded Attributes" = Table.ExpandRecordColumn(#"Removed Other Columns", "Attributes", {"Content Type", "Kind", "Size"}, {"Content Type", "Kind", "Size"}),
#"fx_Size(KB)" = Table.AddColumn(#"Expanded Attributes", "Size(KB)", each [Size]/1024),
#"fx_Size(MB)" = Table.AddColumn(#"fx_Size(KB)", "Size(MB)", each [Size]/1048576),
#"fx_Size(GB)" = Table.AddColumn(#"fx_Size(MB)", "Size(GB)", each [Size]/1073741824),
fx_FolderRoot = Table.AddColumn(#"fx_Size(GB)", "Folder Root", each valueRootFolderSearch),
helper_LenFolderPathFull = Table.AddColumn(fx_FolderRoot, "LenFolderPathFull", each Text.Length([Folder Path Full])),
fx_FolderDepth = Table.AddColumn(helper_LenFolderPathFull, "Folder Depth", each Text.End([Folder Path Full], [LenFolderPathFull]-lenRootFolderSearch+1)),
#"helperList_ListFoldersDepth-Top2" = Table.AddColumn(fx_FolderDepth, "tmp_ListFoldersDepth", each List.Skip(
List.FirstN(
List.RemoveNulls(
Text.Split([Folder Depth],"\")
)
,3)
,1)),
#"ListFoldersDepth-Top2" = Table.TransformColumns(#"helperList_ListFoldersDepth-Top2",
{"tmp_ListFoldersDepth", each "\" & Text.Combine(List.Transform(_, Text.From), "\") & "\"
, type text}),
#"Select Needed Columns" = Table.SelectColumns(#"ListFoldersDepth-Top2",{"Name", "Folder Root", "Folder Depth", "tmp_ListFoldersDepth", "Content Type", "Kind", "Size", "Size(KB)", "Size(MB)", "Size(GB)"}),
#"rename_FoldersParent(1-2)" = Table.RenameColumns(#"Select Needed Columns",{{"tmp_ListFoldersDepth", "Folders Parent (1-2)"}})
in
#"rename_FoldersParent(1-2)"
Folder File Sizes_xlsx.png

Folder File Sizes_xlsx2.png
