Advanced file renaming tool with regex and case transformation support
Project description
renx - Advanced File Renaming Tool
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:
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
- Include/exclude files with
- Safe operations 🛡️:
- Dry-run mode by default (
--actto execute) preview changes before executing - Bottom-up or top-down processing
- Dry-run mode by default (
📦 Installation
pip install renx
🚀 Usage
python -m renx [OPTIONS] [PATHS...]
Basic Examples
-
Dry-run preview (default behavior):
python -m renx /path/to/files
-
Convert filenames to lowercase:
python -m renx --lower /path/to/files
-
Actually perform renames (disable dry-run):
python -m renx --act --lower /path/to/files
-
Make filenames URL-safe:
python -m renx --urlsafe /path/to/files
Regex Substitutions Format
The substitution pattern uses this format:
❗REGEX❗REPLACEMENT❗FLAGS
Where:
- The first character (❗) after
-sor--subsacts as the delimiter - 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':
- Delimiter =
/ - Regex =
foo - Replacement =
bar - 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
-
Process only matching files:
python -m renx --name '*.txt' --lower /path/to/files
-
Exclude directories:
python -m renx --exclude 'temp/*' /path/to/files
-
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b827ca70d26edc8a5fe9837321f75c5714c47a2ec4cfdf1787d6672fabaf66e
|
|
| MD5 |
84e0753a5698b92756545f791919d7c3
|
|
| BLAKE2b-256 |
76979148187ae58428560d5e18b6bd3e618ce8096ed9d5c8af5738ef98c1b210
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
053d6228824dfcc6e1271950941252e41f7cbb835c4645191a786da827dd7ead
|
|
| MD5 |
d2538bf9118140f225c7a7fd52d288d1
|
|
| BLAKE2b-256 |
93b7c2cb7a7da0cbebf459131d358a0cab1de0c2c31ce79aa59e976b82985145
|