<div align="center">
<img src="assets/dirstuff-banner.png">
<h1>dirstuff</h1>
<p>
<strong>utilities for filesystem operations</strong>
</p>
<br>
<div>
<a href="https://badge.fury.io/py/dirstuff"><img src="https://badge.fury.io/py/dirstuff.svg" alt="PyPI"></a>
<a href="https://pepy.tech/project/dirstuff"><img src="https://pepy.tech/badge/dirstuff" alt="Downloads"></a>
</div>
<br>
</div>
## Installation
Install the current PyPI release:
```bash
pip install dirstuff
```
## Path utilities
dirstuff provides some Python utilities for interacting with the filesystem.
- rename
- move
- copy
- delete
- walk
### Rename files with a regex
In this example we iterate over nested folders that contain .txt files and rename them to have .md extensions.
```python
from dirstuff import Dir
d = Dir("my_folder")
for sub in d.iter_dirs():
for f in sub.iter_files():
f.rename_regex(r"([a-z]*)\.txt", r"\1.md")
```
### Delete a folder
No need to switch between `pathlib` and `shutil` packages. All filesystem utilities are available on the `Dir` class.
```python
from dirstuff import Dir
d = Dir("my_folder")
d.delete()
```
## Summarization
### Tree
Summarize a directory recursively by file size. This tool can be used to quickly search a drive for large files taking up too much space.
```bash
# Summarize the /home/user/my_documents directory
# showing only directories greater than 20MB in size
$ dirstuff tree /home/user/my_documents --size 20MB
```
```python
|-> 69.0 GB > my_documents
|-> 67.8 GB > movies
|-> 62.0 GB > from_the_internet
|-> 5.8 GB > home_movies
|-> 638.1 MB > photos
|-> 368.2 MB > rock_concert
|-> 251.6 MB > vacation_2019
|-> 18.4 MB > family_photos
|-> 521.6 MB > work
|-> 263.8 MB > boring_docs
|-> 257.7 MB > reports
|-> 22.5 MB > games
```
> You can show the full absolute paths with `--absolute`
### Search
Search for all folders with a matching name.
```bash
# List all node_modules folders under the /code/projects directory
$ dirstuff search /code/projects node_modules --absolute
```
```python
|-> 419.6 MB > /code/projects/portfolio/web/node_modules
|-> 320.3 MB > /code/projects/fun_project/node_modules
|-> 298.1 MB > /code/projects/simple_game/version_2/node_modules
```
> The same `--size` option also works with the search command
Raw data
{
"_id": null,
"home_page": "https://github.com/gregorybchris/dirstuff",
"name": "dirstuff",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "directory, file, summary",
"author": "Chris Gregory",
"author_email": "christopher.b.gregory@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/32/d3/fc1f3ee37cd39bcba8f074a001d5f098600b13022be81422681b8c9047eb/dirstuff-0.2.0.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n <img src=\"assets/dirstuff-banner.png\">\n <h1>dirstuff</h1>\n\n <p>\n <strong>utilities for filesystem operations</strong>\n </p>\n\n <br>\n <div>\n <a href=\"https://badge.fury.io/py/dirstuff\"><img src=\"https://badge.fury.io/py/dirstuff.svg\" alt=\"PyPI\"></a>\n <a href=\"https://pepy.tech/project/dirstuff\"><img src=\"https://pepy.tech/badge/dirstuff\" alt=\"Downloads\"></a>\n </div>\n <br>\n</div>\n\n## Installation\n\nInstall the current PyPI release:\n\n```bash\npip install dirstuff\n```\n\n## Path utilities\n\ndirstuff provides some Python utilities for interacting with the filesystem.\n\n- rename\n- move\n- copy\n- delete\n- walk\n\n### Rename files with a regex\n\nIn this example we iterate over nested folders that contain .txt files and rename them to have .md extensions.\n\n```python\nfrom dirstuff import Dir\n\nd = Dir(\"my_folder\")\nfor sub in d.iter_dirs():\n for f in sub.iter_files():\n f.rename_regex(r\"([a-z]*)\\.txt\", r\"\\1.md\")\n```\n\n### Delete a folder\n\nNo need to switch between `pathlib` and `shutil` packages. All filesystem utilities are available on the `Dir` class.\n\n```python\nfrom dirstuff import Dir\n\nd = Dir(\"my_folder\")\nd.delete()\n```\n\n## Summarization\n\n### Tree\n\nSummarize a directory recursively by file size. This tool can be used to quickly search a drive for large files taking up too much space.\n\n```bash\n# Summarize the /home/user/my_documents directory\n# showing only directories greater than 20MB in size\n$ dirstuff tree /home/user/my_documents --size 20MB\n```\n\n```python\n|-> 69.0 GB > my_documents\n |-> 67.8 GB > movies\n |-> 62.0 GB > from_the_internet\n |-> 5.8 GB > home_movies\n |-> 638.1 MB > photos\n |-> 368.2 MB > rock_concert\n |-> 251.6 MB > vacation_2019\n |-> 18.4 MB > family_photos\n |-> 521.6 MB > work\n |-> 263.8 MB > boring_docs\n |-> 257.7 MB > reports\n |-> 22.5 MB > games\n```\n\n> You can show the full absolute paths with `--absolute`\n\n### Search\n\nSearch for all folders with a matching name.\n\n```bash\n# List all node_modules folders under the /code/projects directory\n$ dirstuff search /code/projects node_modules --absolute\n```\n\n```python\n |-> 419.6 MB > /code/projects/portfolio/web/node_modules\n |-> 320.3 MB > /code/projects/fun_project/node_modules\n |-> 298.1 MB > /code/projects/simple_game/version_2/node_modules\n```\n\n> The same `--size` option also works with the search command\n",
"bugtrack_url": null,
"license": "Apache Software License",
"summary": "Directory summary tool.",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/gregorybchris/dirstuff",
"Repository": "https://github.com/gregorybchris/dirstuff"
},
"split_keywords": [
"directory",
" file",
" summary"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e8b1f1e27377808410ce5c9d5d29371f47211dba38c71e5c3664ba1e4a1f33c8",
"md5": "914bf43aa5ab385cff02cc6f46c7ad72",
"sha256": "e22fdded7909e67475c5044394b4cc382a625085b758f59de3faaf62f2b1d74c"
},
"downloads": -1,
"filename": "dirstuff-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "914bf43aa5ab385cff02cc6f46c7ad72",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 12716,
"upload_time": "2024-06-30T02:06:12",
"upload_time_iso_8601": "2024-06-30T02:06:12.188002Z",
"url": "https://files.pythonhosted.org/packages/e8/b1/f1e27377808410ce5c9d5d29371f47211dba38c71e5c3664ba1e4a1f33c8/dirstuff-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "32d3fc1f3ee37cd39bcba8f074a001d5f098600b13022be81422681b8c9047eb",
"md5": "eb4d2cf27e7b3b8fc3442269c85a3e70",
"sha256": "f989cbfe02c3909fd75cb66078bd0f0a96dd2d9e60461aab72d00398b175898b"
},
"downloads": -1,
"filename": "dirstuff-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "eb4d2cf27e7b3b8fc3442269c85a3e70",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 12351,
"upload_time": "2024-06-30T02:06:13",
"upload_time_iso_8601": "2024-06-30T02:06:13.617191Z",
"url": "https://files.pythonhosted.org/packages/32/d3/fc1f3ee37cd39bcba8f074a001d5f098600b13022be81422681b8c9047eb/dirstuff-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-30 02:06:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gregorybchris",
"github_project": "dirstuff",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "dirstuff"
}