Regular expressions bulk rename tool for multiple files
Project description
regex-rename
Regular expressions bulk rename tool for multiple files
Usage
enter regex-rename
for help:
$ regex-rename
regex-rename v0.1.0 (nuclear v1.1.5) - Regular expressions bulk rename tool for multiple files
Usage:
regex-rename [OPTIONS] PATTERN [REPLACEMENT]
Arguments:
PATTERN - Regex pattern to match filenames
[REPLACEMENT] - Replacement regex pattern for renamed files. Use \1, \2 syntax to make use of matched groups
Options:
--version - Print version information and exit
-h, --help [SUBCOMMANDS...] - Display this help and exit
--rename - Does actual renaming files instead of just testing replacement pattern
--full - Enforces matching full filename against pattern
Installation
pip3 install regex-rename
Requirements:
- Python 3.6 (or newer) with pip
Example
Imagine you've got audio files awfully named like this:
Stanis▯aw+Lem+Niezwyci▯▯ony+(0001).mp3
Stanis▯aw+Lem+Niezwyci▯▯ony+(0002).mp3
- ...
Stanis▯aw+Lem+Niezwyci▯▯ony+(0051).mp3
and you want to rename all of them in manner 01-Niezwyciężony.mp3
(extracting number from the end and put it at the beginning and shortening it to 2 digits by the way).
Step 1: Testing matching pattern
Our Regex pattern to match those files and extract 2 digit number should be like this: .+\(00(\d{2})\).+
Let's test matching pattern:
Notice that regex groups are extracted in logs.
Step 2: Testing replacement pattern
We'd like to replace all files to a pattern: \1-Niezwyciężony.mp3
(\1
is a first extracted group from matching pattern)
Let's test it:
Step 3: Actual renaming
All above commands were just testing our patterns so that we could experiment with regex patterns. Only when we're sure that everything is matched correctly, we can use --rename
flag which does the actual renaming:
After that files are named properly:
01-Niezwyciężony.mp3
02-Niezwyciężony.mp3
- ...
51-Niezwyciężony.mp3
Project details
Release history Release notifications | RSS feed
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
Hashes for regex_rename-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b4be6f93c22f0ce1c952bb075eeedc18897bc066ecad916c0984fa5eaf6fa93 |
|
MD5 | c28a0024c097d556d71bb4a9d2c4f689 |
|
BLAKE2b-256 | fda8f4e9352d99368bd6ed95d137e2f208e948249022be3d5bafa775e31eb559 |