Note:
If you have Opus 12 or above then you may already have a version of this script.
It is in the default menus under Edit > Toggle Size Format.
Overview
This is a button/script which toggles the Size and/or Size-On-Disk columns between auto mode (showing bytes, KB, MB, GB, etc. depending on each size) and exact bytes.
I normally prefer the auto mode; it lets me quickly know how big something is without having to count how many digits there are. However, sometimes I need to see and compare sizes down to the exact byte. I don't want the exact sizes often enough to keep both columns visible at once, but the ability to quickly toggle between the two formats is ideal.
There are old versions of this button which just used a couple of non-scripting commands. They only toggled the Size column, not Size-On-Disk, and they only worked properly if Size was the second column. The script fixes both limitations.
Installation:
- Download Toggle Size Format.dcf (4.3 KB)
- Select Settings > Customize Toolbars.
- Drag Toggle Size Format.dcf to where you want it on your toolbars or menus.
- Click OK in the Customize window.
History:
- v2.0 19/Feb/2025 - Handles more size columns and retains sort order.
- v1.0 16/Dec/2015 - First script version.
The script itself:
If you're interested in how the Toggle Size Format.dcf download above works, this is the script code it runs.
(You don't need to worry about this if you just want to use the button.)
Function OnClick(ByRef clickData)
sizeIdx = -1
sizeKbIdx = -1
sizeAutoIdx = -1
disksizeIdx = -1
disksizeKbIdx = -1
disksizeAutoIdx = -1
idx = 0
For Each colItem in clickData.func.sourcetab.format.columns
If (colItem.name = "size") Then sizeIdx = idx
If (colItem.name = "sizekb") Then sizeKbIdx = idx
If (colItem.name = "sizeauto") Then sizeAutoIdx = idx
If (colItem.name = "disksize") Then disksizeIdx = idx
If (colItem.name = "disksizekb") Then disksizeKbIdx = idx
If (colItem.name = "disksizeauto") Then disksizeAutoIdx = idx
idx = idx + 1
Next
Set cmd = clickData.func.command
sort_cmd = ""
If (cmd.IsSet("SORTBY=size SORTREVERSE=off")) Then
sort_cmd = "Set SORTBY=size SORTREVERSE=off"
ElseIf (cmd.IsSet("SORTBY=size SORTREVERSE=on")) Then
sort_cmd = "Set SORTBY=size SORTREVERSE=on"
ElseIf (cmd.IsSet("SORTBY=disksize SORTREVERSE=off")) Then
sort_cmd = "Set SORTBY=disksize SORTREVERSE=off"
ElseIf (cmd.IsSet("SORTBY=disksize SORTREVERSE=on")) Then
sort_cmd = "Set SORTBY=disksize SORTREVERSE=on"
End If
If (sizeIdx <> -1 And sizeAutoIdx = -1 And sizeKbIdx = -1) Then
cmd.RunCommand "Set COLUMNSREMOVE=size COLUMNSADD=sizeauto(" & sizeIdx & ")"
ElseIf (sizeIdx = -1 And sizeAutoIdx <> -1 And SizeKbIdx = -1) Then
cmd.RunCommand "Set COLUMNSREMOVE=sizeauto COLUMNSADD=size(" & sizeAutoIdx & ")"
ElseIf (sizeIdx = -1 And sizeAutoIdx = -1 And SizeKbIdx <> -1) Then
cmd.RunCommand "Set COLUMNSREMOVE=sizekb COLUMNSADD=size(" & sizeKbIdx & ")"
End If
If (disksizeIdx <> -1 And disksizeAutoIdx = -1 And disksizeKbIdx = -1) Then
cmd.RunCommand "Set COLUMNSREMOVE=disksize COLUMNSADD=disksizeauto(" & disksizeIdx & ")"
ElseIf (disksizeIdx = -1 And disksizeAutoIdx <> -1 And disksizeKbIdx = -1) Then
cmd.RunCommand "Set COLUMNSREMOVE=disksizeauto COLUMNSADD=disksize(" & disksizeAutoIdx & ")"
ElseIf (disksizeIdx = -1 And disksizeAutoIdx = -1 And disksizeKbIdx <> -1) Then
cmd.RunCommand "Set COLUMNSREMOVE=disksizekb COLUMNSADD=disksize(" & disksizeKbIdx & ")"
End If
If (sort_cmd <> "") Then
cmd.RunCommand sort_cmd
End If
End Function
