Giter Club home page Giter Club logo

detox's Introduction

detox

detox is a Python tool that can be used to rename directories/files with unsafe characters or spaces1.

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

Footnotes

  1. The name detox is inspired by the tool detox.

detox's People

Contributors

alyetama avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.