Skip to content

Command line tool to analyze and visualize disk usage

License

Notifications You must be signed in to change notification settings

mlange-42/dirstat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dirstat

Tests

A command line tool for analyzing and visualizing disk usage.

Screenshot
Example visualizing the Go repository using a treemap

Example visualizing the dirstat repository using a text-based directory tree

Installation

Using Go:

go install github.com/mlange-42/dirstat@latest

Without Go:

Download binaries for your OS from the Releases.

Features

  • Visualize disk usage as text-based tree or as graphical treemap (SVG)
  • Optional visualization of directory content by file extension
  • Exclusion of files and directories by glob patterns
  • Adjustable depth for individual display vs. aggregation
  • Write analysis to JSON and re-read for visualization, for handling large directories
  • Determines the size of large directories 4x faster than Windows Explorer, and 3x faster than PowerShell

Usage

Get help:

dirstat -h
dirstat <command> -h

Basic usage

To view a text-based directory tree, use without a subcommand:

dirstat

Options

Run for a different directory (paths can be absolute or relative):

dirstat --path ../..

Analyze with a different depth than the default plain list:

dirstat --depth 2

Exclude files and directories by glob patterns:

dirstat --exclude .git,*.exe

Aggregate by file extensions:

dirstat -x

Sort by size (or count, or age):

dirstat --sort size

Sort by size and show only the top 90%:

dirstat --sort size --cutoff 90

For more options, see the CLI help dirstat -h.

Treemap

To generate graphical treemaps, use the treemap command.

Generate the treemap and write it to out.svg (can be viewed with any web browser):

dirstat treemap > out.svg

Immediately open the created SVG with the default associated program (ideally a web browser):

dirstat treemap > out.svg && out.svg

Options

Statistics over file extensions:

dirstat treemap -x > out.svg

Size boxes by file count instead of size:

dirstat treemap --count > out.svg

Produce CSV output for use with github.com/nikolaydubina/treemap:

dirstat treemap --csv

For more options to customize the treemap, see the CLI help dirstat treemap -h.

JSON

With subcommand json, the result of the analysis is written to STDOUT in JSON format. If piped to a file, it can be re-used for visualization by using it in the --path flag.

Analyze the current directory and write JSON to out.json:

dirstat json > out.json

Read the JSON instead of running an analysis, and print the directory tree in plain text format:

dirstat --path out.json

References

About

Command line tool to analyze and visualize disk usage

Topics

Resources

License

Stars

Watchers

Forks

Languages