dirstat

command module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2022 License: MIT Imports: 1 Imported by: 0

README

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 by 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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL