Skip to main content

A terminal-based bulk file renamer with a TUI

Project description

PyPI version Downloads License GitHub stars

renux

A terminal-based bulk file renamer with a TUI

Preview

About

renux is a tool with a text-based (terminal) user interface (TUI) that automates file renaming. It simplifies this task with features like regex, placeholders, and text transformations, making it ideal for situations such as renaming photos, cleaning up download folders, or enforcing consistent naming conventions.

Features

  • Regex: perform advanced renaming with pattern matching, capturing groups, and replacements.
  • Text transformations: apply text transformations like slugify, camelCase to snake_case, and more.
  • Counter placeholders: add incremental counters (e.g., file1.txt, file2.txt) with customizable starting points, increments, and padding.
  • Date placeholders: include file creation/modification dates or the current date in filenames with customizable formats.
  • Backup and undo/redo: save and restore changes to your files.
  • File exclusion: exclude files from renaming.
  • Keyboard shortcuts: use hotkeys to quickly apply actions and navigate the UI.

Installation

Using pipx (recommended).

pipx install renux

Alternatively, you can use pip.

Usage

renux [directory] [pattern] [replacement]
  • directory: Directory where files are located (default is the current directory or .).
  • pattern: Search pattern, which can be a regular expression (default is '').
  • replacement: Replacement string for the pattern (default is '').

Options

  • -c COUNT, --count COUNT: Max replacements per file (default is 0, meaning unlimited).
  • -r, --regex: Treats the pattern as a regular expression (default is True).
  • --case-sensitive: Makes the search case-sensitive (default is False).
  • --apply-to: Specifies where the renaming should be applied. Options are:
    • name: Rename the file's base name (default).
    • ext: Rename the file's extension.
    • both: Rename both the name and extension.

Markup

  • Text transformations: {string|operation}

    • slugify: Convert into a URL/filename-friendly format (e.g., "hello world" → "hello-world")
    • lower: Convert to lowercase
    • upper: Convert to uppercase
    • caps: Capitalize the first letter
    • title: Capitalize each word
    • camel: Convert to camel case (e.g., "hello world" → "helloWorld")
    • pascal: Convert to pascal case (e.g., "hello world" → "HelloWorld")
    • snake: Convert to snake case (e.g., "hello world" → "hello_world")
    • kebab: Convert to kebab case (e.g., "hello world" → "hello-world")
    • swapcase: Swap the case (e.g., "Hello World" → "hELLO wORLD")
    • reverse: Reverse the string (e.g., "Hello World" → "dlroW olleH")
    • strip: Remove leading and trailing whitespace
    • len: Get the length of the string
  • Counter: {counter(start=1,step=1,padding=1)}, e.g., {counter(1,2,3)} will generate a sequence like 001, 003, 005, ...

  • Dates: {now|created_at|modified_at(<format>)}, e.g., {now(%Y)} will replace it with the current year

Run python project.py -h for more details.

Examples

  • Rename files starting with "IMG" to "Image":
    python project.py my_photos/ IMG_ Image_
    
  • Rename all .txt files to .bak:
    python project.py my_directory/ .txt .bak --apply-to ext
    
  • Use regex to retain information from the old name:
    python project.py my_documents "document (\d).pdf" "doc (\1).pdf" -r
    
  • Append a counter to filenames:
    python project.py my_files/ file "file_{counter}"
    
  • Append creation year to filenames:
    python project.py my_files/ file "file_{created_at(%Y)}"
    
  • Apply transformations like slugify:
    python project.py my_files "(.*)" "{filename|slugify}" -r
    

Dev Setup

  1. Clone the repo
    git clone https://github.com/andrianllmm/renux.git
    cd renux
    
  2. Create and activate a virtual environment
    python -m venv venv
    source venv/bin/activate  # or `venv\Scripts\activate` on Windows
    
  3. Install the dependencies
    pip install -r requirements.txt
    

Testing

Run tests with:

pytest

Contributing

Contributions are welcome! To get started:

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a pull request

Issues

Found a bug or issue? Report it on the issues page.

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

renux-0.1.2a0.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

renux-0.1.2a0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file renux-0.1.2a0.tar.gz.

File metadata

  • Download URL: renux-0.1.2a0.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.18 Linux/6.6.87.1-microsoft-standard-WSL2

File hashes

Hashes for renux-0.1.2a0.tar.gz
Algorithm Hash digest
SHA256 51681a81e06e636b9d89b923747feafabd659d9c22a461aa5bfe30712566de87
MD5 9a640025695324020ef1dd5b865a3595
BLAKE2b-256 a289e076b9b0f2e0daa006cba4ef2bec69dac63d6eb88ee87b18e83883e2663f

See more details on using hashes here.

File details

Details for the file renux-0.1.2a0-py3-none-any.whl.

File metadata

  • Download URL: renux-0.1.2a0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.18 Linux/6.6.87.1-microsoft-standard-WSL2

File hashes

Hashes for renux-0.1.2a0-py3-none-any.whl
Algorithm Hash digest
SHA256 2539d96eb39ae3789a0af2166c211742073287601d069ff80b23999ea7bb18c8
MD5 470d062e9f3689dbf5d7c2222d31a428
BLAKE2b-256 994a78f768a0612afc0437551a5708e37cb48384a023357cb55ac170cb7173b2

See more details on using hashes here.

Supported by

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