Page MenuHomePhabricator

Abbreviate file sizes instead of showing bytes
Closed, ResolvedPublic


Big Pallooka suggested:

Could you please look at specifying what the units used are and maybe an option to choose a unit size. The size of folders in the print out is different to what Windows Explorer shows and now that drives can hold folders with terabytes of data numbers begin to be meaningless at first glance.

These should be abbreviated by SI or traditional units. Could use Windows configuration, or let user select between SI or traditional units (i.e., K = 1000, k = 1024)

FOLDER	X:\Large Downloads\	-------	3	10	18,161,480,454	18,161,480,454
FILE	474,389,552		39A1A3F3BE5698A67ACD19162695E37E8040D5C0
FILE	1,505,170,121		AF43306CF26F2F54A10342E37AEE406442EC2CCF
FILE	4,604,166,144	Climate Change.iso		123ECFF05CA0427DB8403A6DCB7A7948B274DCEC
FILE	305,135,616	debian-9.4.0-amd64-netinst.iso		DA34180D8F618A6A311FE31FB08508496EB91601
FILE	1,676,083,200	linuxmint-18.2-cinnamon-64bit.iso		0294FDEDFD0FECB84F8B10E290461003DA675229
FILE	1,266,643,148	Moto_X_Pure_3r_Gen_(2015)-X2_WELTE2CA-NorthAmerica_US_Retail_XT1575_MPH24.49-18_18.gz		8C6A82421C734586673B8E61125A9F165A769670
FILE	1,217,341,440	tails-amd64-3.4.iso		277AFECD059BE34536D78AF388BE0FC5FE8A4D8B
FILE	833	tails-amd64-3.4.iso.sig		6B6EC05ADF8BBEFB6C3F814E8A6DE087417508F0
FILE	3,473,729,536	Win10_1709_English_x32.iso		93B317C82B69252027E57AA2D18B50825CDF443E
FILE	3,638,820,864	Windows.iso		245E484BC3F81029DE27ED893A05EAD929C7AFA6
FOLDER	X:\Large Downloads\CLARK_RETUS_7.0_NPH25.200-22_cid9_subsidy-DEFAULT_CFC\	-------	1	0	0	0
FOLDER	X:\Large Downloads\CLARK_RETUS_7.0_NPH25.200-22_cid9_subsidy-DEFAULT_CFC\CLARK_RETUS_7.0_NPH25.200-22_cid9_subsidy-DEFAULT_CFC.xml\	-------	0	22	2,725,175,659	2,725,175,659
FILE	41,943,040	boot.img		BA519534FDEB5335E50176735AC83CA423CC0E63
FILE	2,764,288	bootloader.img		DA8823A1E95C89C6CCB075B177DFE03EB21E97ED
FILE	1,334,576	BTFM.bin		6C90DD90EF28BE9FE17C8F30A81C8C5AAF70A7DD

Event Timeline

Joe created this task.May 26 2018, 6:50 AM
Joe triaged this task as Wishlist priority.
Joe shifted this object from the Restricted Space space to the S5 Public space.May 26 2018, 6:58 AM
Joe changed the visibility from "All Users" to "Public (No Login Required)".
Joe added a comment.EditedOct 28 2018, 3:43 PM


On Windows 10:

2690 / 1024 = 2.x -- So: Traditional units and truncated, not rounded.

Unit reference, for fun

Joe raised the priority of this task from Wishlist to High.Oct 28 2018, 3:45 PM
Joe added a comment.Oct 28 2018, 5:59 PM

Umm, what?


PWSTR StrFormatByteSizeW(
  PWSTR    pszBuf,
  UINT     cchBuf

The first parameter of this function has different types for the ANSI and Unicode versions. If your numeric value is a DWORD, you can use StrFormatByteSize with text macros for both cases. The compiler will cast the numerical value to a LONGLONG for the Unicode case. If your numerical value is a LONGLONG, you should use StrFormatByteSizeW explicitly.

In Windows 10, size is reported in base 10 rather than base 2. For example, 1 KB is 1000 bytes rather than 1024.

The following table illustrates how this function converts a numeric value into a text string.

Numeric valueText string
532532 bytes
13401.30 KB
2350622.9 KB
x2.28 MB
x2.23 GB
Joe closed this task as Resolved.Oct 28 2018, 7:21 PM

This was confusing. :)

There are now 4 ways to format the byte sizes:

  1. All Digits (Directory Printer classic ) - Total bytes, no rounding, no abbreviation, formatted for your Windows locale
  2. 1 KB = 1024 B (Old School) - Abbreviated to 3 or 4 digits plus KB, MB, GB, TB, etc
  3. 1 KB = 1024 B (Explorer-style in KB) - Same as Size column in Windows Explorer on Windows 10, in Kilobytes
  4. 1 KB = 1000 B (Metric) - Same as Old School except metric: 1000 bytes is 1 KB, x bytes is 1 MB, etc