Menu

Tree [ae4dab] master /
 History

HTTPS access


File Date Author Commit
 .settings 2020-09-08 Michael Fross Michael Fross [f50010] Major rewrite of the code. Not 100% complete, ...
 graphics 2020-09-10 Michael Fross Michael Fross [9d8308] Added ScreenShot to graphics folder
 snap 2020-12-09 Michael Fross Michael Fross [ae4dab] Updated versioning standard from date to Major....
 src 2020-11-17 Michael Fross Michael Fross [a4ff73] Changed map fill character from '*' to 'o'
 .classpath 2020-09-08 Michael Fross Michael Fross [f50010] Major rewrite of the code. Not 100% complete, ...
 .gitignore 2020-07-01 Michael Fross Michael Fross [22f23a] Initial commit
 .project 2020-07-02 Michael Fross Michael Fross [d275a3] Started testing some thread usage.
 LICENSE 2020-07-01 Michael Fross Michael Fross [af517d] Just starting. Added license and snapcraft file
 README.md 2020-11-04 Michael Fross Michael Fross [ea3344] Corrected Typos in the README
 pom.xml 2020-12-09 Michael Fross Michael Fross [ae4dab] Updated versioning standard from date to Major....

Read Me

DirSize: The Command Line Directory Reporting Tool

DirSize

DirSize is a directory reporting tool. It recursively scans the provided (or current) directory, and reports the number of files and director sizes of each subdirectory present. It also defaults to sorting by by directory size, but there are other options.

Lastly, it's written in Java and packaged into a single executable JAR file. All of the dependencies built in so it should run anywhere. Howver, I've only tested it on Windows 10 and Ubuntu.

Maps

One of the interesting things about DirSize is it shows a visual representation of the file sizes of counts. I call this a SizeMap or FilesMap and it's the area to the right of the output. If you sort by size (default or -ss) or directories (-sd) is will show the SizeMap. If sorted by file counts (-sf) the map will change to show a visual representation of the number of files per subdirectory, sorted from high to low.

Command-Line Options

Usage:

java -jar dirsize.jar [-D] [-x <filename>] [-ss|-sf|-sd][-r] [-c width] [-v] [-h|?] [Directory]

Option Description
-D Run program in debug mode. This will display quite a bit of information on the program as it's running. I usually use this as I debug the program, but if you wish to get a bit more insight into what's going on, go for it.
-x FileName Export the results as a CSV to the file provided
-ss Sort output by the directory sizes. This is the default
-sf Sort output by the number of files
-sd Sort output by directory name
-r Reverse the sort order. Ascending or descending will depend on the sorting type selected. File and Size sorting will be displayed in ascending order. Directory sorting will be displayed alphabetically in reverse order
-e Suppress error display. Normally, issues with scanning are display at the end of the output. With this switch enabled, this list will be suppressed. Scanning errors usually happen when DirSize does not have permission to a file or folder although there can be other reasons
-c Width Set By default, DirSize uses the full console width. However, you can change this. Useful if you have a very wide console display
-v Simply display the program version and exit
-h | -? Display the program help

Examples

java -jar dirsize.jar

Display a size sorted report from the current directory

java -jar dirsize.jar -sd C:\Apps

Display a directory name sorted report from the C:\Apps directory

java -jar dirsize.jar -c 80 -sf /home/jimbob

Display a file number sorted report from the jimbob's home dir using 100 columns

java -jar dirsize.jar -x $HOME/usr-output.csv /usr

Output the directory report of /usr into a CSV file in my home directory

SNAP

dirsize

I would encourage anyone with a supported Linux platform to use snap. See Snapcraft Homepage for more information. You can download, install, and keep DirSize up to date automatically by installing the snap. You don't even have to have java as it's bundled within the snap virtual machine. Install via:

sudo snap install dirsize (Assuming snapd is installed)

Get it from the Snap Store

Note:

Snap applications run in a container and by default do not have rights to see files on the filesystem outside of this 'sandbox.' In order to use DirSize, it needs to be able see file names and sizes. The interface system-backup gives it that right. Therefore, to use dirsize , you need to allow it to read file information by executing:

sudo snap connect dirsize:system-backup

If you change your mind, you can remove this permission by executing:

sudo snap disconnect dirsize:system-backup

Wrapup

I'm making this freely available in the hope that others may find this useful. Please let me know if you have any issues, thoughts or suggestions for enhancements by mailing dirsize@fross.org.

License

The MIT License

Copyright (C) 2011-2020 by Michael Fross

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.