# pytree
A Python CLI utility for visualizing folder trees with sizes and counts.
## Installation
pytree requires **Python version 3.8+** in order to run. You can install pytree in your Python environment with the command:
```shell
pip install pytree2
```
## Usage
```shell
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
```shell
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.
```shell
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:
```shell
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.
Raw data
{
"_id": null,
"home_page": null,
"name": "pytree2",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "python, cli, tree, folder structure, file size, disk usage",
"author": null,
"author_email": "Angelo Luiz Angonezi <angeloangonezi2@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/e2/9c/1042a5abe988c843267b6096c7cacff69727642276d5fe924d0ffc4f4c97/pytree2-0.2.1.tar.gz",
"platform": null,
"description": "# pytree\r\nA Python CLI utility for visualizing folder trees with sizes and counts.\r\n\r\n## Installation\r\n\r\npytree requires **Python version 3.8+** in order to run. You can install pytree in your Python environment with the command:\r\n```shell\r\npip install pytree2\r\n```\r\n\r\n## Usage\r\n\r\n```shell\r\npytree [-h] [-d] [-s] [-c] [-x EXTENSION] [-k KEYWORD] [-l LEVEL] [start_path ...]\r\n```\r\n\r\n```\r\npytree - a python cli utility for visualizing folder trees with sizes and counts\r\n\r\npositional arguments:\r\n start_path defines path to directory to start building the tree\r\n\r\noptional arguments:\r\n -h, --help show this help message and exit\r\n -d, --dirs-only tree displays directories only, and does not show files inside folders\r\n -s, --show-sizes tree displays files and folder sizes, in mega or gigabytes\r\n -c, --show-counts tree displays the number of files or folders inside each directory\r\n -x EXTENSION, --extension EXTENSION\r\n tree will include only files that match given extension (e.g. \".txt\", \".pdf\")\r\n -k KEYWORD, --keyword KEYWORD\r\n tree will include only files that contain specific keyword on file name\r\n -l LEVEL, --level LEVEL\r\n defines tree's depth (until which subfolder tree will be created) [0=start_path, -1=all]\r\n```\r\n\r\n### Examples\r\n\r\n#### Basic usage\r\n```shell\r\npytree test_folder\r\n```\r\n\r\n```\r\ntest_folder\r\n\u251c\u2500\u2500 another_folder\r\n\u2502 \u251c\u2500\u2500 empty_folder\r\n\u2502 \u2514\u2500\u2500 one_mb_file.txt\r\n\u2514\u2500\u2500 folder\r\n \u251c\u2500\u2500 a_python_file.py\r\n \u251c\u2500\u2500 folder_inside_folder\r\n \u2502 \u251c\u2500\u2500 not_a_text_file.pdf\r\n \u2502 \u251c\u2500\u2500 ten_kb_file.txt\r\n \u2502 \u2514\u2500\u2500 two_mb_file.txt\r\n \u2514\u2500\u2500 ten_mb_file.txt\r\n```\r\n\r\n#### Using optional arguments\r\nBy concatenating the optional arguments, you can get a clear view of the folder structure.\r\nAdditionally, pytree will print a summary line in the end, with the folder/file count and total size.\r\n```shell\r\npytree test_folder -dcs\r\n```\r\n\r\n```\r\ntest_folder [2] (13 mb)\r\n\u251c\u2500\u2500 another_folder [2] (1 mb)\r\n\u2502 \u2514\u2500\u2500 empty_folder [0] (0 bytes)\r\n\u2514\u2500\u2500 folder [3] (12 mb)\r\n \u2514\u2500\u2500 folder_inside_folder [3] (2 mb)\r\n\r\n5 folders, 6 files, 13 mb\r\n```\r\n\r\n#### Specifying extension/keyword\r\nYou can also specify a search keyword (by passing **-x** your_extension) or keyword (by passing **-k** your_keyword), e.g:\r\n```shell\r\npytree test_folder -cs -x .pdf\r\n```\r\n\r\n```\r\ntest_folder [2] (136 bytes)\r\n\u251c\u2500\u2500 another_folder [1] (0 bytes)\r\n\u2502 \u2514\u2500\u2500 empty_folder [0] (0 bytes)\r\n\u2514\u2500\u2500 folder [1] (136 bytes)\r\n \u2514\u2500\u2500 folder_inside_folder [1] (136 bytes)\r\n \u2514\u2500\u2500 not_a_text_file.pdf (136 bytes)\r\n\r\n5 folders, 6 files (1 valid), 136 bytes\r\n```\r\nNotice that by using this option together with the **-c** and **-s** flags, the counts and sizes in the final summary\r\nline will contain a counter for files matching search criteria, and the total size will reflect only matching files,\r\nproviding an easy and quick way of scanning folders and identifying large files of a specified extension/keyword.\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python CLI utility for visualizing folder trees with sizes and counts.",
"version": "0.2.1",
"project_urls": {
"Homepage": "https://github.com/angelo-angonezi/pytree",
"Issues": "https://github.com/angelo-angonezi/pytree/issues"
},
"split_keywords": [
"python",
" cli",
" tree",
" folder structure",
" file size",
" disk usage"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "10ec906030f1c84d421f13fc716ff67383d30ba22d66a72669989025cc398439",
"md5": "a370f2987686a8ee00cd1c49bcda8965",
"sha256": "73ab983fa021e46091c7b351c91e14c7e0a1b9e515f52eeaaba85545e9ebbc4f"
},
"downloads": -1,
"filename": "pytree2-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a370f2987686a8ee00cd1c49bcda8965",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 15719,
"upload_time": "2025-09-01T11:30:16",
"upload_time_iso_8601": "2025-09-01T11:30:16.839477Z",
"url": "https://files.pythonhosted.org/packages/10/ec/906030f1c84d421f13fc716ff67383d30ba22d66a72669989025cc398439/pytree2-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "e29c1042a5abe988c843267b6096c7cacff69727642276d5fe924d0ffc4f4c97",
"md5": "00d37d1abaa5a26c1634e9e68e2683e1",
"sha256": "db903b9a50cd8788a4968304fbe80456ef6d7f82a41c1beea9bba1bacbf5497e"
},
"downloads": -1,
"filename": "pytree2-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "00d37d1abaa5a26c1634e9e68e2683e1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 14654,
"upload_time": "2025-09-01T11:30:17",
"upload_time_iso_8601": "2025-09-01T11:30:17.795627Z",
"url": "https://files.pythonhosted.org/packages/e2/9c/1042a5abe988c843267b6096c7cacff69727642276d5fe924d0ffc4f4c97/pytree2-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-01 11:30:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "angelo-angonezi",
"github_project": "pytree",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pytree2"
}