- Guest
Human-readable file size?
Advertisement
I think this question may be asked before. I did some search, but didn't get answer. Does WinSCP have human-readable file size scaling as commonly seen as the -h switch in ls and du commands? For example, 2500 bytes -> 2.4 KB, 1234567 bytes -> 1.2 MB. FileZilla seems have such an option, but I like WinSCP better. :D
Advertisement
-
martin◆
Site Admin - Joined:
- Posts:
- 41,441
- Location:
- Prague, Czechia
Re: Human-readable file size?
WinSCP shows human readable size on file properties dialog. I suppose you want it on file panel?
- Guest
Re: Human-readable file size?
Yes, or more precisely in the explorer panel, like Windows Explorer and many other similar applications do. It is annoying to right-click -> left-click on more than 100 files, isn't it? I suppose it is not that difficult to implement, but quit useful for users.
P.S. In my WinSCP, I don't have the "Calculate" button as shown in the screenshot. Is it only available in certain cases?
Thanks for reply!
P.S. In my WinSCP, I don't have the "Calculate" button as shown in the screenshot. Is it only available in certain cases?
Thanks for reply!
-
martin◆
Site Admin
Re: Human-readable file size?
This request has been added to tracker.
- TomR
- Joined:
- Posts:
- 1
- Location:
- NYC
I was taking a look at this bug, I made some progress on it.
In UnixDirView.cpp first I added a function to display filesizes in a human readable format:
Then I changed TUnixDirView::GetDisplayInfo
But this only affects the remote pane not the local pane. I couldn't for the life of me find where that was happening.
Later on, I found the FormatBytes function in GUITools.cpp. If you add a reference to GUITools.h at the top of UnixDirView.cpp, you can use that function and ignore mine completely:
I kept looking and I eventually found that the display for the local pane was governed by a Pascal Function FormatSize in BaseUtils.pas. I edited those two functions to format the size in the same manner as FormatBytes.
Searching for "#,##0" brings up some other locations where the filesize should probably be edited. But when I edited those, I didn't see any change, so since I can't test that code, I left it alone.
I hope this helps - I decided I needed to kick myself and contribute something to Open Source.
In UnixDirView.cpp first I added a function to display filesizes in a human readable format:
AnsiString TUnixDirView::FormatFileSize(__int64 size) { const __int64 B = 1; const __int64 KB = 1024 * B; const __int64 MB = 1024 * KB; const __int64 GB = 1024 * MB; if(size > GB) return FormatFloat("0.## GB", size / GB); else if(size > MB) return FormatFloat("0.## MB", size / MB); else if(size > KB) return FormatFloat("0.## KB", size / KB); else return FormatFloat("0.## b", size); }
Then I changed TUnixDirView::GetDisplayInfo
case uvSize: // expanded from ?: to avoid memory leaks if (!File->IsDirectory) { Value = FormatFileSize(File->Size); } break;
But this only affects the remote pane not the local pane. I couldn't for the life of me find where that was happening.
Later on, I found the FormatBytes function in GUITools.cpp. If you add a reference to GUITools.h at the top of UnixDirView.cpp, you can use that function and ignore mine completely:
case uvSize: // expanded from ?: to avoid memory leaks if (!File->IsDirectory) { Value = FormatBytes(File->Size); } break;
I kept looking and I eventually found that the display for the local pane was governed by a Pascal Function FormatSize in BaseUtils.pas. I edited those two functions to format the size in the same manner as FormatBytes.
function FormatSize(Size: Cardinal): string; var i: Integer; p: Integer; suffix: string; begin p := 0; i := 3; if Size < (100*1024) then begin {b} suffix := ' B'; end else if Size < (100*1024*1024) then begin {KB} Size := Cardinal(Round(Size / 1024)); suffix := ' KiB'; end else begin {MB} Size := Cardinal(Round(Size / (1024 * 1024))); suffix := ' MiB'; end; Result := IntToStr(Size); while i + p < Length(Result) do begin Insert(ThousandSeparator, Result, Length(Result) - (i + p)+ 1); Inc(p); INC(i, 3); end; Insert(Suffix, Result, Length(Result) + 1) end; {FormatSize} function FormatSize(Size: Int64): String; var i: Integer; p: Integer; suffix: string; begin p := 0; i := 3; if Size < (100*1024) then begin {b} suffix := ' B'; end else if Size < (100*1024*1024) then begin {KB} Size := Round(Size / 1024); suffix := ' KiB'; end else begin {MB} Size := Round(Size / (1024 * 1024)); suffix := ' MiB'; end; Result := IntToStr(Size); while i + p < Length(Result) do begin Insert(ThousandSeparator, Result, Length(Result) - (i + p)+ 1); Inc(p); Inc(i, 3); end; Insert(Suffix, Result, Length(Result) + 1) end; {FormatSize}
Searching for "#,##0" brings up some other locations where the filesize should probably be edited. But when I edited those, I didn't see any change, so since I can't test that code, I left it alone.
I hope this helps - I decided I needed to kick myself and contribute something to Open Source.
Advertisement
-
martin◆
Site Admin
Thanks Tom. I have raised priority for this.
- pandaking
- Joined:
- Posts:
- 1
Bump
+1
I'd much rather in my file list it showed "KB", "MB", "GB" etc. than the current system.
Any news on adding this feature?
I'd much rather in my file list it showed "KB", "MB", "GB" etc. than the current system.
Any news on adding this feature?
-
mattcredp
Guest
has this functionality been added? I can't find the option on my install (4.3.3 build1340)
- Robotobo
- Joined:
- Posts:
- 2
There are 3 options in Show file sizes in: Bytes, Kilobytes, Short Format
Short Format only shows in Megabytes but doesn't show in Gigabytes.
Can we please add Gigabytes?
+1
Short Format only shows in Megabytes but doesn't show in Gigabytes.
Can we please add Gigabytes?
+1
Advertisement
-
martin◆
Site Admin - Joined:
- Posts:
- 41,441
- Location:
- Prague, Czechia
It should show Gigabytes. As with other units, only if the files is at least 100 units large (100 GB in this case).There are 3 options in Show file sizes in: Bytes, Kilobytes, Short Format
Short Format only shows in Megabytes but doesn't show in Gigabytes.
Can we please add Gigabytes?
+1
- Robotobo
- Joined:
- Posts:
- 2
I have a 2GB file, why does it show in Megabytes?
If I have files that are over 1024 Megabytes each, I want to show them in Gigabytes, not megabytes.
I haven't seen any program that forcefully shows files in megabytes when files are 1-10 gigabyte files.
Every FTP/SFTP program supports showing filesizes in gigabytes, why does a file have to 100 GB to show in gigabytes in WinSCP?
---
For example in attached file below, file is over 1024 Megabytes or 1000 Megabytes (whatever notation you are going for)
And it says 1.074 MB, it looks like it's 1 Megabytes and has few other kilobytes
It doesn't look right to me, no operating system does this
If I have files that are over 1024 Megabytes each, I want to show them in Gigabytes, not megabytes.
I haven't seen any program that forcefully shows files in megabytes when files are 1-10 gigabyte files.
Every FTP/SFTP program supports showing filesizes in gigabytes, why does a file have to 100 GB to show in gigabytes in WinSCP?
---
For example in attached file below, file is over 1024 Megabytes or 1000 Megabytes (whatever notation you are going for)
And it says 1.074 MB, it looks like it's 1 Megabytes and has few other kilobytes
It doesn't look right to me, no operating system does this
-
martin◆
Site Admin - Joined:
- Posts:
- 41,441
- Location:
- Prague, Czechia
What every FTP/SFTP client?Every FTP/SFTP program supports showing filesizes in gigabytes, why does a file have to 100 GB to show in gigabytes in WinSCP?
Anyway, thanks for your suggestion.
Will see if more people ask for this.
-
jwruffin
Guest
file sizes
I'll chime in that I'd also like to see this implemented. Should switch units when the file size is over 1 unit, not 100 as it does currently. Files that are 1,500 MB should show up as 1.46 GB, etc. Threshold of 100 units is too high.
Advertisement
-
foy
Guest
As martin wants to see more people asking, I'm with jwruffin. It would be much more useful (informative, intuitive, immediate) to me that WinSCP (best there is) stepped up the unit the moment it passes the 1, no threshold.
Kudos
Kudos
-
martin◆
Site Admin - Joined:
- Posts:
- 41,441
- Location:
- Prague, Czechia
This request has been added to the tracker:What every FTP/SFTP client?Every FTP/SFTP program supports showing filesizes in gigabytes, why does a file have to 100 GB to show in gigabytes in WinSCP?
Anyway, thanks for your suggestion.
Will see if more people ask for this.
https://winscp.net/tracker/1530
I'm sending you an email with a development version of WinSCP to the address you have used to register on this forum.
Advertisement
You can post new topics in this forum