Skip to main content

Advanced file renaming tool with regex and case transformation support

Project description

renx - Advanced File Renaming Tool

Python Version PyPI version fury.io

renx is a powerful command-line utility for batch renaming files and directories with advanced pattern matching and transformation capabilities.

☕ Support

If you find this project helpful, consider supporting me:

ko-fi

Features ✨

  • Pattern-based renaming 🧩 - Use regex substitutions to transform filenames
  • Smart case conversion 🔠 - Convert to lowercase (--lower) or uppercase (--upper)
  • URL-safe names 🌐 - Clean filenames for web use (--urlsafe)
  • Precise file selection 🎯:
    • Include/exclude files with --includes/--excludes
    • Control traversal depth with --max-depth
  • Safe operations 🛡️:
    • Dry-run mode by default (--act to execute) preview changes before executing
    • Bottom-up or top-down processing

📦 Installation

pip install renx

🚀 Usage

python -m renx [OPTIONS] [PATHS...]

Basic Examples

  1. Dry-run preview (default behavior):

    python -m renx /path/to/files
    
  2. Convert filenames to lowercase:

    python -m renx --lower /path/to/files
    
  3. Actually perform renames (disable dry-run):

    python -m renx --act --lower /path/to/files
    
  4. Make filenames URL-safe:

    python -m renx --urlsafe /path/to/files
    

Regex Substitutions Format

The substitution pattern uses this format:

❗REGEX❗REPLACEMENT❗FLAGS

Where:

  1. The first character (❗) after -s or --subs acts as the delimiter
  2. The pattern is split into parts by this delimiter

Examples

Simple substitution

-s '/old/new/'
  • Replaces first occurrence of "old" with "new" in each filename

3. Using different delimiters

-s '|old|new|'
  • Uses | as delimiter instead of /

4. Case-insensitive substitution

-s ':old:new:i'
  • Replaces "old", "Old", "OLD", etc. with "new"

5. Complex patterns

-s '/\d+/_/'
  • Replaces one or more digits with an underscore

Supported Flags

The tool supports these regex flags (see Python's re module for complete reference):

Flag Meaning
i Case-insensitive matching
m Multi-line matching
s Dot matches all (including \n)
x Verbose (ignore whitespace)

For example, with -s '/foo/bar/i':

  1. Delimiter = /
  2. Regex = foo
  3. Replacement = bar
  4. Flags = i (case-insensitive)

Important Notes

  • The delimiter can be any character (but must not appear unescaped in the pattern)
  • The tool compiles the regex with the specified flags before applying it

Practical Examples

  • Replace spaces with underscores:

    renx -s '/ /_/' /path/to/files
    
  • Remove special characters:

    renx -s '/[^a-zA-Z0-9.]//' /path/to/files
    
  • Add prefix to numbered files:

    renx -s '/(\d+)/image_\1/' *.jpg
    
  • Fix inconsistent extensions (case-insensitive):

    renx -s '/\.jpe?g$/.jpg/i' *
    

Filtering Options

  1. Process only matching files:

    python -m renx --name '*.txt' --lower /path/to/files
    
  2. Exclude directories:

    python -m renx --exclude 'temp/*' /path/to/files
    
  3. Limit recursion depth:

    python -m renx --max-depth 2 /path/to/files
    

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

renx-0.0.4.tar.gz (26.8 kB view details)

Uploaded Source

Built Distribution

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

renx-0.0.4-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file renx-0.0.4.tar.gz.

File metadata

  • Download URL: renx-0.0.4.tar.gz
  • Upload date:
  • Size: 26.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for renx-0.0.4.tar.gz
Algorithm Hash digest
SHA256 8b827ca70d26edc8a5fe9837321f75c5714c47a2ec4cfdf1787d6672fabaf66e
MD5 84e0753a5698b92756545f791919d7c3
BLAKE2b-256 76979148187ae58428560d5e18b6bd3e618ce8096ed9d5c8af5738ef98c1b210

See more details on using hashes here.

File details

Details for the file renx-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: renx-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for renx-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 053d6228824dfcc6e1271950941252e41f7cbb835c4645191a786da827dd7ead
MD5 d2538bf9118140f225c7a7fd52d288d1
BLAKE2b-256 93b7c2cb7a7da0cbebf459131d358a0cab1de0c2c31ce79aa59e976b82985145

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