If you have Opus 12 or above then you may already have a slightly improved version of this script.
It is in the default menus under Edit > Toggle Size Format, and handles a few additional columns compared to the original version below.
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 and toggles the format of both columns wherever they are found.
- Download Toggle Size Format.dcf (2.27 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.
- v1.0 16/Dec/2015 - First script version.
The script itself:
If you just want to use the script, the Toggle Size Format.dcf download above is probably easier.
The script code is reproduced here so people looking for scripting techniques can see the script code without downloading anything.
@script vbscript Function OnClick(ByRef clickData) sizeIdx = -1 sizeAutoIdx = -1 disksizeIdx = -1 disksizeAutoIdx = -1 idx = 0 For Each colItem in clickData.func.sourcetab.format.columns If (colItem.name = "size") Then sizeIdx = idx If (colItem.name = "sizeauto") Then sizeAutoIdx = idx If (colItem.name = "disksize") Then disksizeIdx = idx If (colItem.name = "disksizeauto") Then disksizeAutoIdx = idx idx = idx + 1 Next Set cmd = clickData.func.command If (sizeIdx <> -1 And sizeAutoIdx = -1) Then cmd.RunCommand "Set COLUMNSREMOVE=size COLUMNSADD=sizeauto(" & sizeIdx & ")" ElseIf (sizeIdx = -1 And sizeAutoIdx <> -1) Then cmd.RunCommand "Set COLUMNSREMOVE=sizeauto COLUMNSADD=size(" & sizeAutoIdx & ")" End If If (disksizeIdx <> -1 And disksizeAutoIdx = -1) Then cmd.RunCommand "Set COLUMNSREMOVE=disksize COLUMNSADD=disksizeauto(" & disksizeIdx & ")" ElseIf (disksizeIdx = -1 And disksizeAutoIdx <> -1) Then cmd.RunCommand "Set COLUMNSREMOVE=disksizeauto COLUMNSADD=disksize(" & disksizeAutoIdx & ")" End If End Function