Skip to main content

A Python CLI utility for visualizing folder trees with sizes and counts.

Project description

pytree

A Python CLI utility for visualizing folder trees with sizes and counts.

Installation

pytree requires Python version 3.9+ in order to run. You can install pytree in your Python environment with the command:

pip install pytree2

Usage

pytree [-h] [-d] [-s] [-c] [-x EXTENSION] [-k KEYWORD] [-l LEVEL] [start_path ...]
pytree - a python cli utility for visualizing folder trees with sizes and counts

positional arguments:
  start_path            defines path to directory to start building the tree

optional arguments:
  -h, --help            show this help message and exit
  -d, --dirs-only       tree displays directories only, and does not show files inside folders
  -s, --show-sizes      tree displays files and folder sizes, in mega or gigabytes
  -c, --show-counts     tree displays the number of files or folders inside each directory
  -x EXTENSION, --extension EXTENSION
                        tree will include only files that match given extension (e.g. ".txt", ".pdf")
  -k KEYWORD, --keyword KEYWORD
                        tree will include only files that contain specific keyword on file name
  -l LEVEL, --level LEVEL
                        defines tree's depth (until which subfolder tree will be created) [0=start_path, -1=all]

Examples

Basic usage

pytree test_folder
test_folder
├── another_folder
│   ├── empty_folder
│   └── one_mb_file.txt
└── folder
    ├── a_python_file.py
    ├── folder_inside_folder
    │   ├── not_a_text_file.pdf
    │   ├── ten_kb_file.txt
    │   └── two_mb_file.txt
    └── ten_mb_file.txt

Using optional arguments

By concatenating the optional arguments, you can get a clear view of the folder structure. Additionally, pytree will print a summary line in the end, with the folder/file count and total size.

pytree test_folder -dcs
test_folder [2] (13 mb)
├── another_folder [2] (1 mb)
│   └── empty_folder [0] (0 bytes)
└── folder [3] (12 mb)
    └── folder_inside_folder [3] (2 mb)

5 folders, 6 files, 13 mb

Specifying extension/keyword

You can also specify a search keyword (by passing -x your_extension) or keyword (by passing -k your_keyword), e.g:

pytree test_folder -cs -x .pdf
test_folder [2] (136 bytes)
├── another_folder [1] (0 bytes)
│   └── empty_folder [0] (0 bytes)
└── folder [1] (136 bytes)
    └── folder_inside_folder [1] (136 bytes)
        └── not_a_text_file.pdf (136 bytes)

5 folders, 6 files (1 valid), 136 bytes

Notice that by using this option together with the -c and -s flags, the counts and sizes in the final summary line will contain a counter for files matching search criteria, and the total size will reflect only matching files, providing an easy and quick way of scanning folders and identifying large files of a specified extension/keyword.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytree2-0.1.4.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytree2-0.1.4-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file pytree2-0.1.4.tar.gz.

File metadata

  • Download URL: pytree2-0.1.4.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for pytree2-0.1.4.tar.gz
Algorithm Hash digest
SHA256 39eb5de5c4dd8d55a71de44b6745f1a49f6ae768823684e51f6e412bf9d9aea7
MD5 adca2f6cf94e5f79ced327eb604ce888
BLAKE2b-256 9c197b4170e8812ec72fe38619e6e8c810e16edd2d18a70e337157215767ec5f

See more details on using hashes here.

File details

Details for the file pytree2-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: pytree2-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for pytree2-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9cbbd7dada6cac82185d45303f0d3862185175da9be6abbc09ee0958f799765b
MD5 ea434dc17f62fc7fd55b4446ac75cf29
BLAKE2b-256 67bb3783947ba9b307a2564c35798d621a7dbafba7c3544b4b4fbc589b5f81f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page