nested-rimraf
Nested rimraf CLI app.
Use it to clear your junk in nested directories Looks for target file/directory through specified tree and then removes everything
Practice
Imaginary folder structure:
/subject
→ /file
→ /node_modules // file, not directory
→ /node_modules
→ /enemy.txt
→ /sub
→ /2
→ /1
→ /4
→ /node_modules
→ /enemy.txt
→ /3
→ /node_modules
→ /enemy.txt
→ /sub2
→ /node_modules
→ /enemy.txt
→ /symlink
→ /example
→ /enemy.txt
→ /node_modules // symlink to /subject/symlink/example
Tasks:
- Find all
node_modules - Find and remove all
node_modules - Find and remove all directories named
node_modules - Find and remove all
node_modules, but do not remove symlinks [Ultimate]Find allnode_modules, except files and symlinks, save them to file, correct file and remove the remaining
1. Find all node_modules
We need to run scan command with target=node_modules and directory=./subject
$> nested-rimraf scan node_modules ./subject
Files and directories (include symlinks):
→ subject/node_modules
→ subject/symlink/node_modules
→ subject/file/node_modules
→ subject/sub/node_modules
→ subject/sub/3/node_modules
→ subject/sub/2/1/4/node_modules
→ subject/sub2/node_modules
2. Find and remove all node_modules
As easy, as previous one. Just use rm instead of scan
$> nested-rimraf rm node_modules ./subject
Files and directories (include symlinks):
→ subject/node_modules
→ subject/symlink/node_modules
→ subject/file/node_modules
→ subject/sub/node_modules
→ subject/sub/3/node_modules
→ subject/sub/2/1/4/node_modules
→ subject/sub2/node_modules
Are you sure you want to delete it? [y/N]: y
Done flawlessly!
Note: Question Are you sure you want to delete it? [y/N]: y may be avoided with --agree/-y option. Like that:
$> nested-rimraf rm -y node_modules ./subject
Files and directories (include symlinks):
→ subject/node_modules
→ subject/symlink/node_modules
→ subject/file/node_modules
→ subject/sub/node_modules
→ subject/sub/3/node_modules
→ subject/sub/2/1/4/node_modules
→ subject/sub2/node_modules
Done flawlessly!
3. Find and remove all directories named node_modules
Ok, lets add option --dir-only/-d
$> nested-rimraf rm -y node_modules ./subject --dir-only
Directories (include symlinks):
→ subject/node_modules
→ subject/symlink/node_modules
→ subject/sub/node_modules
→ subject/sub/3/node_modules
→ subject/sub/2/1/4/node_modules
→ subject/sub2/node_modules
Done flawlessly!
As you can see, there is no subject/file/node_modules in the list (because it's file, not a directory).
Let's run something similar
4. Find and remove all node_modules, but do not remove symlinks
Same pattern:
$> nested-rimraf rm -y node_modules ./subject --without-symlinks
Directories (include symlinks):
→ subject/node_modules
→ subject/file/node_modules
→ subject/sub/node_modules
→ subject/sub/3/node_modules
→ subject/sub/2/1/4/node_modules
→ subject/sub2/node_modules
Done flawlessly!
Let's try the hardest one, shall we?
5. [Ultimate] Find all node_modules, except files and symlinks, save them to file, correct file and remove the
remaining
Human control, eh?
$> nested-rimraf scan -dsL node_modules ./subject --save-path ./subject/to_correct.txt
Directories (exclude symlinks):
→ subject/node_modules
→ subject/sub/node_modules
→ subject/sub/3/node_modules
→ subject/sub/2/1/4/node_modules
→ subject/sub2/node_modules
Successfully saved list to "subject/to_correct.txt"
A lot of params:
-d- same as--dir-only. Includes only directories-s- same as--without-symlinks. Excludes symlinks-L- same as--save-list. Saves list of matches to file--save-path- path to save matches
What does this file contain? Nothing special, just list of files
$> cat ./subject/to_correct.txt
subject/node_modules
subject/sub/node_modules
subject/sub/3/node_modules
subject/sub/2/1/4/node_modules
subject/sub2/node_modules
Let's take it easy and save subject/sub/node_modules by removing it from the file.
And, 3, 2, 1, clear!
$> nested-rimraf rmf -yds ./subject/to_correct.txt
Directories (enclude symlinks):
→ subject/node_modules
→ subject/sub/3/node_modules
→ subject/sub/2/1/4/node_modules
→ subject/sub2/node_modules
Done flawlessly!
Good job!
Usage:
$ nested-rimraf [OPTIONS] COMMAND [ARGS]...
Options:
--install-completion: Install completion for the current shell.--show-completion: Show completion for the current shell, to copy it or customize the installation.--help: Show this message and exit.
Commands:
rm: Scan and remove targets inside directory and...rmf: Took file, generated by "nested-rimraf scan"...scan: Scan directory and child-directories to find...
nested-rimraf rm
Scan and remove targets inside directory and sub-directories
Usage:
$ nested-rimraf rm [OPTIONS] TARGET [DIRECTORY]
Arguments:
TARGET: Target name to find inside of directory [required][DIRECTORY]: Directory to scan in [default: .]
Options:
-d, --dir-only: Target only directories [default: False]-s, --without-symlinks: Do not process symlinks as targets [default: False]-y, --agree: Remove without any questions [default: False]-I, --ignore-errors: Ignore errors and delete until possible [default: False]-v, --verbose: Talk a lot [default: False]--help: Show this message and exit.
nested-rimraf rmf
Took file, generated by "nested-rimraf scan" and remove everything from it
Usage:
$ nested-rimraf rmf [OPTIONS] [SAVE_PATH]
Arguments:
[SAVE_PATH]: Remove list from passed file or ".nr-todo" inside passed directory [default: .nr-todo]
Options:
-d, --dir-only: Target only directories [default: False]-s, --without-symlinks: Do not process symlinks as targets [default: False]-y, --agree: Remove without any questions [default: False]-I, --ignore-errors: Ignore errors and delete until possible [default: False]-v, --verbose: Talk a lot [default: False]--help: Show this message and exit.
nested-rimraf scan
Scan directory and child-directories to find targets
Usage:
nested-rimraf scan
Usage:
$ nested-rimraf scan [OPTIONS] TARGET [DIRECTORY]
Arguments:
TARGET: Target name to find inside of directory [required][DIRECTORY]: Directory to scan in [default: .]
Options:
-d, --dir-only: Target only directories [default: False]-s, --without-symlinks: Do not process symlinks as targets [default: False]-L, --save-list: Save list of targets for further use [default: False]--save-path TEXT: File to save list of targets [default: .nr-todo]-v, --verbose: Talk a lot [default: False]--help: Show this message and exit.
Metadata
Release files for nested-rimraf 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nested-rimraf-1.0.1.tar.gz | 18.7 kB | Without provenance | Details for nested-rimraf-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nested_rimraf-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for nested_rimraf-1.0.1-py3-none-any.whl |
Total release size: 38.1 kB
Release files / nested-rimraf-1.0.1.tar.gz
| Download URL | nested-rimraf-1.0.1.tar.gz |
|---|---|
| Size | 18.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
82a27d4f98d1ba94bae678d6086ce0316f2df6744ccda6eb816b1169b2ff6663
|
|
BLAKE2b-256 checksum How to use checksums |
b77cb769d0b0423aedb17bfc6e59b218c170737dc9d732c9e013db9d42f1ed3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.2 Darwin/21.5.0
|
Release files / nested_rimraf-1.0.1-py3-none-any.whl
| Download URL | nested_rimraf-1.0.1-py3-none-any.whl |
|---|---|
| Size | 19.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
97543a756d6738a86970e2b36efec9dcb9e8cc50bd8c15b018811f9fa9acadee
|
|
BLAKE2b-256 checksum How to use checksums |
86a1118902ff8552830a3764e9186c2512f71e8e4e0f0287a40b1523f74a5f10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.2 Darwin/21.5.0
|
Security for nested-rimraf 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.