Skip to main content

A tool to rename directories/files that contain unsafe characters

Project description

detox

detox is a Python tool that can be used to rename directories/files with unsafe characters or spaces[^1].

Supported Python versions PEP8 Poetry-build

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 detox 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.4.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

detoxpy-0.1.4-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: detoxpy-0.1.4.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.10.5 Darwin/21.6.0

File hashes

Hashes for detoxpy-0.1.4.tar.gz
Algorithm Hash digest
SHA256 34b1768a9244dde401b47caa424996d38598545bf388dd48968d4fc29e21476a
MD5 4c9f4f583ee282e13dc0f69f612c38f1
BLAKE2b-256 cadf133fa91367cef59e4258d96464b57b8ce2142ad93904a5f34c372cb99e0a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: detoxpy-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.10.5 Darwin/21.6.0

File hashes

Hashes for detoxpy-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e837980e2adbfc7c642d95fa1d4a813955d3b1081aae1fa0b3c101e03746f893
MD5 b469f726f4143b81bca979c0de3a7cc2
BLAKE2b-256 e06ec1d4baa019b25af5cd0047336780672a1b215de43ab11931225d29bfb328

See more details on using hashes here.

Supported by

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