A tool to rename directories/files that contain unsafe characters
Project description
detox
detox
[^1] is a Python tool that can be used to rename directories/files with unsafe characters or spaces.
Requirements
Installation
pip install -U detoxpy
Usage
usage: detox [-h] [-r] [-R REPLACE_WITH] [-t] [-l] [-n] [-p] path [path ...]
positional arguments:
path Path to a single or multiple files/directories to detox
optional arguments:
-h, --help show this help message and exit
-r, --recursive Rename files recursively
-R REPLACE_WITH, --replace-with REPLACE_WITH
Replace spaces and unsafe characters with this character (default: '_')
-t, --keep-trailing Keep the trailing character if exists (e.g., 'foo_')
-l, --keep-leading Keep the leading character if exists (e.g., '_foo')
-n, --dry-run Do a trial run with no permanent changes
-p, --plain-print Print the change as plain text
Examples
Example 1: Detox a single file/directory:
detox '(foo)^bar.txt'
# '(foo)^bar.txt' --> 'foo_bar.txt'
detox 'foo&bar/'
# 'foo&bar' --> 'foo_bar'
Example 2: Detox a directory recursively:
# foo bar
# └── foo1&foo2
# ├── foo bar (copy 1).jpg
# └── foo bar (copy 2).jpg
detox -r 'foo bar'
# foo_bar
# └── foo1_foo2
# ├── foo_bar_copy_1.jpg
# └── foo_bar_copy_2.jpg
Example 3: Duplicate names after detoxing
detox
will avoid overwriting if the detoxed name already exists. For example:
tree 'foo foo'
# foo foo
# ├── foo^bar.jpg
# └── foo%bar.jpg
detox -r -i 'foo foo'
# foo_foo
# ├── foo_bar.jpg
# └── foo_bar-1.jpg
[^1]: The name is inspired by the tool detox
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
detoxpy-0.1.3.tar.gz
(4.6 kB
view details)
Built Distribution
File details
Details for the file detoxpy-0.1.3.tar.gz
.
File metadata
- Download URL: detoxpy-0.1.3.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.10 Darwin/21.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b02c5aa608ef96e96ae8513656ef23969d8f07ede528509b214d13ab5e8fb82 |
|
MD5 | c2494a3e0d1cde03387d496aa5d9f12e |
|
BLAKE2b-256 | 01d145004ed26b810785438c5f7af8c488002576be23c9eb55a5f26073283ad9 |
File details
Details for the file detoxpy-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: detoxpy-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.10 Darwin/21.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9838cedb7fe312dfbd55d92b49e87e9a55809729261b37f2acd8b90f56f2f3bb |
|
MD5 | 5b29be3769d2fd3b8d492ae1391575a9 |
|
BLAKE2b-256 | c86045d6b16169d19a2f378b4997e54b8fb87de0beb77664e879eb2403b082a6 |