SmartGetSizes: Script Command to calculate folder sizes

Requires Opus 11.16 or above.

This script was written as part of another request described in the following discussion:

...but I thought that just this piece of that idea might be of interest to others on it's own.

What does it do?:

This script adds a 'SmartGetSizes' Script Command to Opus. Such commands can be used like any other Opus internal commands directly in toolbar buttons, hotkeys, etc. On first run, SmartGetSizes will calculate the sizes of any selected folders (and all folders if none are selected)... just like the built-in GetSizes command. From there, it differs from the built-in GetSizes command in several ways:

  • If all selected folders have already had their sizes calculated, running the command a second time will subsequently calculate the rest of the folder sizes in the current dir (as would happen if you had run the regular GetSizes command with either ALL or NONE of the folders selected).

  • If all selected folders have already had their sizes calculated, and you then select one or more additional folders, running the command again will only calculate the sizes of the newly selected folders. Running the command yet again without changing any selections will work as just mentioned above in the first bullet.

  • The command supports the use of a NODESELECT option just like the built-in GetSizes command... but also supports a GETALL option as well which forces size calculation of all folders in the current dir regardless of either selection status or existing size calculation.

Note: credit to Jonathan Potter, who wrote the working code that inspired this script command as an early example of a script function to solve the needs of the user in the following discussion:

How to install and use it?:

The script is provided here as an Opus Script Package, which in turn is actually a zip file with a single VBScript packaged inside.


  • 2014-03-28: Initial release...
  • 2014-06-05: v1.0.5 - the VBScript version was updated. The update fixes a missing variable declaration noticed by qiuqiu (thanks again).
  • 2015-12-27: v1.2.0 - scripts renamed to match my new standard, also added a DEBUG_CLEAR option to clear the output log between script runs, and minimum required Opus version is now set to 11.16.
  • 2016-11-22: v1.2.2 - Fixed an issue with an incorrect variable name and logic error when one or more selected folders did not have it's size already calculated. NOTE: that with this latest version, I am only maintaining the VBscript version. However, I've left the previous Jscript version 1.2.0 posted for posterity.

The script package can be installed by either manually copying the OSP file to the /dopusdata\Script AddIns folder, or via drag-and-drop into the Preferences / Toolbars / Scripts page.

The only script configuration options available are the DEBUG and DEBUG_CLEAR options that control logging of messages to the Opus Output Window.

After installing the script package, you can then use the command just like any other Opus command:

1 Like

ScriptCommand_SmartGetSizes (vb).osp

ScriptCommand_SmartGetSizes: 发生错误于 88,位置 7
ScriptCommand_SmartGetSizes: 变量未定义: 'file' (0x800a01f4)

Dim fGetAll, fNoDeselect, objCmd, file

Thanks... not sure how I missed that during final testing before posting. Hmmm...

I'm updating the root post with a fixed version of the script, and will make the same update to the version in the original script this was packaged with.

Root post updated with new version... no ~functional change other than some renaming of scripts to match a new standard I've settled on as well as added an option to clear log messages between script runs.

Root post updated with a few small corrections.