# DirSizeCalc

Version 2.22

DirSizeCalc is a content plug-in for the file manager Total Commander. It provides several numeric calculation for directory contents. The calculations can be started automatically while entering a directory or explicitly by the user.

## Contents

1. Field descriptions
2. System requirements
3. Use
   1. Use cases
      1. Display directory and file sizes automatically
      2. Delete empty directory trees
      3. Find out if compression makes sense
      4. Find out how many directory are contained in a directory
      5. Find out if a directory contains subdirectories
      6. Load the directory size for all selected or all fields by pressing a keystroke
   2. Additional information for displayed values
   3. Size display for (almost) empty directories
   4. Placeholders
4. Settings
   1. Field settings
      1. Name
      2. Field selection
      3. Loading behavior
      4. Reparse point behavior
      5. Recursive
      6. Cache values
      7. Calculation limit
   2. Unit settings
      1. Name
      2. Prefixes and units
      3. Formatting
      4. Preview
   3. Change settings file location
5. Frequently asked questions
6. Author contact
7. License

## 1. Field descriptions

Size | File- or directory size
Compressed Size | File- or directory size with set compressed attribute. This field is only available on Windows NT based operating systems.
Compression Ratio | Calculates the ratio between Size and Compressed Size.
Subdirectory Count | Count of all subdirectories in a directory
File Count | Count of all files in a directory.
Empty | Finds out if a directory is empty
Contains Files | Finds out of a directory contains files.
Contains subdirectories | Finds out of a directory contains subdirectories.

## 2. System requirements

Total Commander 6.50 is required for this plug-in. Total Commander 7.03 is recommended for this plug-in.

## 3. Use

Before DirSizeCalc's fields can be used they must be added to the part of Total Commander where they are intended to be used. Basically all content plug-ins can be used in the same way. The following program parts of Total Commander support content plug-ins.

- Custom columns views
- Tooltips
- Thumbnal view
- Find files
- Colors by file type
- Overwrite dialog
- Multi rename tool

### 3.1 Use cases

#### 3.1.1. Display size of files and directories automatically

##### Custom columns view

Total Commander provides to calculate the size of directories by executing the command cm_CountDirContent (Hotkey Shift+Alt+Enter). An automatic calculation each time a directory is entered isn't possible though. By using the field "Size" the directory sizes are displayed as fast as possible. In the following explains step by step who this can be setup.

1. Open the configuration dialog by clicking Configuration/Options in the main menu.
2. Navigate to the page "Custom columns".
3. Click the "New" button to create a new custom columns view.
4. You can setup the number of columns and its contents n this dialog. Click the "Add column" button. A new row with properties is displayed. This row represents the new column's attributes.
5. The next step is to define the new column's contents. Click the + button to assign a field to the column. Select dirsizecalc/Size/<default> in the menu. The property "Field contents" now displays [dirsizecalc.Size]. You can select another unit instead of <default>. Fore more details on this see the "Units" chapter. The property "Title" displays the text which will be displayed in the column header. The title can be changed at will.
6. Click OK to close the dialog "Custom columns".
7. Click OK to close the configuration dialog.

#### 3.1.2. Delete empty directory trees

##### Find files

A large amount of directories containing no files may make it difficult to maintain orientation in the file system. It's a good idea to clean up from time to time. Values provided by content plug-ins such as DirSizeCalc can be used to narrow down the number of found files. So the find files function of Total Commander is used together with with the DirSizeCalc plug-in to find directories containing no files.

1. Click "Search" in the Commands menu.
2. Navigate to the "Plugins" tab.
3. In this tab rules can be defined. For each file and directory in the search scope the defined rules will be checked. Only if the rule applies the file or directory will be added to the list of found files. In this case the rule is Plugin: dirsizecalc, Field: Contains Files, Operator: = and Value: No. In Furthermore the short form is used. In this case this would be dirsizecalc.Contains Files=No. The rule ensures that only directories will be found that contain no files. If a directory contains files or a problem occurred during retrieving the contents the directory won't be found during the search.
4. Click on the button "Start search". Wait until the search has finished.
5. Click on the "Feed to Listbox" button to display the search results in a Total Commander file list panel.
6. Select all directories listed in the search results panel.
7. Apply the delete operation to the selected files. During the process a prompt might be displayed informing you that a directory isn't empty. The statement is true but this is just a directory containing other empty directories. The prompt can be answered by clicking on the "All" button.

Alternatively the rule dirsizecalc.Empty=Yes can be used. In this case the directories will be deleted without warnings as they don't even contain empty subdirectories. The disadvantage is that after deleting new empty subdirectories emerge until no empty directories are found.

It's a good idea to search the search parameters to be able to repeat the search later.

#### 3.1.3. Find out if compression makes sense

##### Custom columns view

##### Find files

The Windows file system NTFS allows you to set the "compressed" attribute to each file. The file is compressed but in contrast to archives you can continue working as if the file were uncompressed. Why are not all files compressed automatically? Reading and writing of compressed files takes longer compared to uncompressed files. For this reason only files should be compressed where write operation are performed infrequently. Many files are archives or files with a high information content. The cannot be further compressed by using NTFS compression. This is where "Compressed Size" and "Compression Rate" come into play. They can be setup the same way as described in the use case "Display size of files and directories automatically" but an additional column "Compressed Size" has to be added. Alternatively you can search for files which couldn't be compressed very good. The search is setup in the same way as described in "Delete empty directory trees" but the rule defined in the "Plugins" tab differs. It could be for example some like this:

- tc.Compressed = yes
- tc.Directory = no
- dirsizecalc.Compressed Size > 80

#### 3.1.4. Find out how many files are contained in a directory

##### Thumbnail view

1. Open the configuration dialog by clicking Configuration/Options in the main menu.
2. Navigate to the page "Thumbnail view".
3. Make sure "Show custom fields below thumbnails" is checked.
4. Enter "Size: " (without quotes) in the fields below.
5. Click on the "Add" button right to the edit field.
6. Select "dirsizecalc/File Count" in the menu.
7. Click OK to close the configuration dialog.

#### 3.1.5. Find out if a directory contains subdirectories

##### Tooltip

1. Open the configuration dialog by clicking Configuration/Options in the main menu.
2. Navigate to the page "Display".
3. Make sure that the options " Show filename in file list as tooltip if truncated" and are activated.
4. Make sure the options "Show file name in file list as tooltip if truncated " and "Win32-style tips with file comments"are activated.
5. Click on the "+" button to create a user-defined tooltip.
6. The dialog "User-defined fields by file type" is displayed. Click on the "Add" button to create a new file type.
7. The dialog "Enter file type" is displayed. Enter *.* to include all directories.
8. Click OK to close the dialog "Enter file type".
9. Now a dialog is displayed which is also labeled "User-defined fields by filetype". First enter "Contains subdirectories: " (without quotes).
10. Clock on the the + button.
11. Select dirsizecalc/Contains subdirectories. In the text fields the following text should be displayed: "Contains subdirectories: [=dirsizecalc.Contains Subdirectories]" (without quotes).
12. Click OK to close the dialog "User-defined fields by file type".
13. Click OK to close the dialog "User-defined fields by file type".
14. Click OK to close the configuration dialog.

The described approach can be used in a slightly modified way to color directories containing subdirectories using the "Colors by file type" function. In this case Total Commander uses DirSizeCalc to process the operation in foreground. For this reason Total Commander until the operation is completed.

#### 3.1.6. Load the directory size for all selected or all fields by pressing a keystroke

Many users don't want that all sizes are calculated automatically. They rather want to know the sizes of all selected or of all displayed directories. Total Commander makes it possible. Here is an example how this can be achieved by pressing a keystroke.

1. Start the included setting tool (DirSizeCalcSetting.exe).
2. Select the "Load on demand" option for the already selected field "Size" in the dialog "Edit field settings".
3. Click OK.
4. Restart Total Commander.
5. Create a new custom column view as described in chapter 3.1.1 .
6. Open the configuration dialog by clicking Configuration/Options in the main menu.
7. Select the page "Misc.".
8. Select the desired hotkey (e.g. Alt+Shift+Enter).
9. Click on the button with the magnifier.
10. Select the "Custom column view" category in the displayed "Choose command" dialog.
11. Select cm_LoadSelOnDemandFields, to calculate the size of all selected directories or cm_LoadAllOnDemandFields to calculate the size of all directories.
12. Click OK to apply the selected command.
13. Click on the button with the checkmark to apply the chosen command.
14. Click OK to close the configuration dialog .
15. Now select the directories to calculate.
16. Press the chosen hotkey .

Once configured you just have to set the created custom column view and the steps 15 and 16. Although the new commands can be found in the "Custom column view" category they also work great in thumbnail view.

### 3.2 Additional values for displayed values

DirSizeCalc shows some tokens in front of the calculation result, if the complete directory content couldn't be retrieved. This can be the case for several reasons:

- AD = Access denied. This error is displayed if the current user has no sufficient access permissions for opening the directory.
- U = Unreadable Unicode name. This error occurs if file name contains characters which don't match the currently set Windows code page and you have deactivated storing of short file names.
- E = Unknown error. Unknown error should not be displayed at all. When it's displayed please report it to me.
- NF = Not followed reparse point. The user has set the option to now follow reparse points which results in not including these these files in the calculation.

### 3.3. Size display of (almost) empty directories

There can be multiple reasons for a directory size of 0 bytes. So far the fields "Leer" and "Contains Files" had to be used to distinguish them but now this information is displayed directly in the "Size" field. The following cases are distinguished:

- The directory contains only files of size 0. In this case DirSizeCalc displays 0 as size.
- The directory contains only empty subdirectories but no files. In this case "No files" is being displayed.
- The directory is really empty In this case "Empty is being displayed.

### 3.4 Placeholders

Calculation of directory can take a long time. For this reason DirSizeCalc displays "Dir." until the actual value has been calculated. If DirSizeCalc detects that the directory is actually a reparse point "Junc. Pt." is displayed for junction points and "Mnt. Pt." is displayed for mount points.

## 4. Settings

The bundled settings tool (DirSizeCalcSettings.exe) can be used to personalize DirSizeCalc. Closing the setting tool will save the settings but Total Commander has to be restarted to apply the changed settings.

### 4.1. Field settings

Field settings can be used to personalize the field's behavior. Initially just predefined fields are available on the "Fields" tab. By clicking on "Add" you can add you own fields. This can be helpful if you want to use a certain field with different behaviors. By clicking "Delete" custom fields can be deleted.

A single click in the list will open a dialog which includes all settings available for the selected field. Please note that not all settings are available to all fields.

#### 4.1.1 Name

This is the field's name for all built-in fields. For custom fields a name set by the user.

#### 4.1.2. Field selection

Here you can pick one of DirSizeCalc's fields .

#### 4.1.3. Loading behavior

This setting only applies to fields used in custom column views and in thumbnail view. By default the values are calculated automatically when opening a directory (setting automatically). If you change this to "on demand" here than you will have to press the space key to load the values of all configured fields for the directory under the cursor.

#### 4.1.4. Reparse point behavior

Reparse points look like normal directories but they point to a disk volume (mount points) or another directory (junction points). By default DirSizeCalc treats reparse points just like normal directories which means the target's directory contents is calculated. This may lead to wrong assumptions on the directory's size and take a long time.

DirSizeCalc provides separated options for mount- and junction points. By unchecking "Follow mount points" respectively "Follow junction points" calculation can be completely deactivated. In addition the option "but not in subdirectories" can be used to treat reparse points like directories in the visible directory level but don't calculate values for reparse points in subdirectories.

#### 4.1.5. Recursive

By default a directory is processed recursively. This means the complete directory including all subdirectories and the directory content of this subdirectories and so on is considered in the calculation. By disabling "Recursive" only the directory content is considered.

#### 4.1.6. Cache values

DirSizeCalc stores the retrieved values in a cache to speed up displaying directory sizes. The cache's disadvantage is that the displayed values are not always up to date. If you want to get the actual directory sizes you can force a reload by executing "Reread source" from the View menu (hotkey: Ctrl+R).

#### 4.1.7. Calculation limit

If you just need approximate values and calculation time is critical you enable a calculation limit. Here you can enter the number of files which should be retrieved for a directory.

When the limit has been reached the calculation the calculation will be aborted and ">=" will by displayed in front of the value. This indicates the the actual value might by much bigger.

### 4.2. Unit settings

The built-in units differ in unit and prefix. Unit defines if and how the size in bytes is converted to another unit. Prefix defines the base on which the calculation is performed.

The so called binary prefixes are based on power of two. The size dimensions are 2^10 =1.024 (= 1 KiB), 2^20 = 1.048.576 (= 1 MiB) and 2^30= 1.073.741.824 (=1 GiB).

The SI prefixes are based on power of ten. The size dimensions differ by a factor of 1000. 1.000 bytes (= 1 kB), 1.000.000 (1 MB) and 1.000.000.000 (= 1 GB).

Many programs - such as Total Commander - calculate based on power of two but use SI prefixes. This presentation is wrong and isn't used by Total Commander for this reason.

Below you'll find a table containing example conversions. Please note that actual presentation depends on the chosen formatting options.

bytes | KiB | MiB | GiB | kB | MB | GB
--- | --- | --- | --- | --- | --- | ---
0 | 0,0 | 0,0 | 0,0 | 0,0 | 0,0 | 0,0
587 | 0,6 | 0,0 | 0,0 | 0,6 | 0,0 | 0,0
1.000 | 1,0 | 0,0 | 0,0 | 1,0 | 0,0 | 0,0
1.024 | 1,0 | 0,0 | 0,0 | 1,0 | 0,0 | 0,0
81.981 | 80,1 | 0,1 | 0,0 | 82,0 | 0,1 | 0,0
101.654 | 99,3 | 0,1 | 0,0 | 101,7 | 0,1 | 0,0
1.000.000 | 976,6 | 1,0 | 0,0 | 1.000,0 | 1,0 | 0,0
1.048.576 | 1.024,0 | 1,0 | 0,0 | 1.048,6 | 1,0 | 0,0
5.400.000 | 5.273,4 | 5,1 | 0,0 | 5.400,0 | 5,4 | 0,0
70.000.000 | 68.359,4 | 66,8 | 0,1 | 70.000,0 | 70,0 | 0,1
1.000.000.000 | 976.562,5 | 953,7 | 0,9 | 1.000.000,0 | 1.000,0 | 1,0
1.073.741.824 | 1.048.576,0 | 1.024,0 | 1,0 | 1.073.741,8 | 1.073,7 | 1,1
6.250.000.000 | 6.103.515,6 | 5.960,5 | 5,8 | 6.250.000,0 | 6.250,0 | 6,3

#### 4.2.1. Name

For built-in units this is the default unit abbreviation. For custom units this is a name defined by the user.

#### 4.2.2. Prefixes and units

DirSizeCalc allows the user to define which unit is used for a certain range of file- and directory sizes. By default bytes is used. First check all other units which you want to use. Than enter the minimum value in bytes where this unit should be used.

If you want to use KiB as the smallest unit you have to enter 0 in the KiB size field.

#### 4.2.3. Formatting

There are a bunch of options to customize the formatting of file- and directory sizes. This includes the number of digits, decimal- and thousand separators and some more.

#### 4.2.4. Preview

This preview displays how directory sizes will be displayed later in Total Commander.

### 4.3 Change the settings location

By default DirSizeCalc stores its settings in the same directory where Wincmd.ini - Total Commander's main settings file - is located. In this dialog you can choose between several locations.

- Same directory as "Wincmd.ini"
- Directory "DirSizeCalc" in "Wincmd.ini" directory.
- Plug-in directory
- Total Commander root directory

To choose a new location please select the desired location from the combo box.

In addition the current path and if this path is writable is displayed.

## 5. Frequently asked questions

Can I use DirSizeCalc to calculate values for all selected or all directories?

Yes this is possible starting from Total Commander 7.50. There is a use case which describes how it works.

I changed to a directory containing many files. Previously I sorted by a column which contained a DirSizeCalc field. Total Commander seems to hang. Is there anything I can do?

Total Commander waits for the calculation to finish and blocks program's use. Trying to abort the calculation (e.g. by hitting Escape) is not handled by Total Commander and for this reason not forwarded to the plug-in. I asked the author of Total Commander to add adda way to abort the calculation as soon as possible.

In the meantime you can use "Calculation limit" option which only calculates a fraction of the directory contents and therefore shortens the waiting time.

Instead of displaying the size of directories in archives just 0 is displayed. Why it doesn't work?

In this case DirSizeCalc would have to get the values from Total Commander. Unfortunately this isn't possible in the current Total Commander version. I asked the author of Total Commander to add this feature as soon as possible.

In earlier versions there have been fields called "in background" and "on demand". Where have they gone?

The default setting is now "in background". If you want to load the values "on demand" you are free to do so. Please start the bundled configuration utility (DirSizeCalcSettings.exe). This tool allows you to set "on demand" loading for each single field or you can even create your own custom field with loading behavior set to "on demand". The reasons for changing the field names have been reducing the field count and shortening of field names. If you added custom columns you had to change the title manually resulted in losing the information anyway.

## 6. Contact

There is a thread in the Total Commander forum which can be used to discuss problems, bug and suggestions.

## 7. License and liability

Any liability for damage of any sort is hereby denied.
All rights reserved. This Total Commander plug-in is copyrighted free ware.