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).mp3Stanis▯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.mp302-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
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 regex-rename-0.1.0.tar.gz.
File metadata
- Download URL: regex-rename-0.1.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94cab307a8f117841ac3da5d3b5398bc2663337f79d3b9bd8ef0e8b01a50b848
|
|
| MD5 |
e65ac3614635feab8cb84403bc89ba32
|
|
| BLAKE2b-256 |
36bf0fc5a8e6db5358fe042ab3d3ed4df07305910a59d5440243a35af9e2c34d
|
File details
Details for the file regex_rename-0.1.0-py3-none-any.whl.
File metadata
- Download URL: regex_rename-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b4be6f93c22f0ce1c952bb075eeedc18897bc066ecad916c0984fa5eaf6fa93
|
|
| MD5 |
c28a0024c097d556d71bb4a9d2c4f689
|
|
| BLAKE2b-256 |
fda8f4e9352d99368bd6ed95d137e2f208e948249022be3d5bafa775e31eb559
|