multi-rename
A python module for renaming multiple files in a directory to a common format ending with incrementing numbers. The increment start and gap between increments is configurable, and a separator string can be specified to be inserted between the new name and the incrementing number.
It also supports adding a prefix or suffix to each file in a directory, with options for a separator strings.
For both full renaming and prefix / suffix renaming, a list of file extensions can be provided as a filter to ignore these files for renaming.
Installation
Install using pip:
pip install multi-rename
Usage
from multi_rename import renamer
# Fully rename all the files with incrementing file numbers, exlcuding any html files
renamer.full_rename(dir_path='/path/to/dir/here', new_name='new_file_name', filter_ext='html')
# Add a prefix to all the files with an underscore separator, excluding any txt files
renamer.add_prefix(dir_path='/path/to/dir/here', prefix='prefix_to_add', sep='_', filter_ext='txt')
# Add a suffix to all the files with a hyphen separator, excluding any pdf files
renamer.add_suffix(dir_path='/path/to/dir/here', suffix='suffix_to_add', sep='-', filter_ext='pdf')
Example
Folder structure with sample files
expenses.xlsx
report.pdf
essay.docx
webpage.html
...
Full rename
renamer.full_rename(dir_path='/home/dir_path/', new_name='print-this', sep='-')
This will rename all the file names in dir_path to print-this followed by a hyphen and incrementing numbers:
print-this-1.xlsx
print-this-2.pdf
print-this-3.docx
print-this-4.html
...
Adding a prefix
renamer.add_prefix(dir_path='/home/dir_path/', prefix='v1', sep='-')
This will rename all the file names in dir_path to start with v1-:
v1-expenses.xlsx
v1-report.pdf
v1-essay.docx
v1-webpage.html
...
Adding a suffix
renamer.add_suffix(dir_path='/home/dir_path/', suffix='old', sep='_')
This will rename all the file names in dir_path to end with _old:
expenses_old.xlsx
report_old.pdf
essay_old.docx
webpage_old.html
...
Changing file extensions
renamer.change_extension(dir_path='/home/dir_path/', new_ext='txt', filter_ext='html')
This will change all the file extensions in dir_path to .txt, except any .html files:
expenses.txt
report.txt
essay.txt
webpage.html
...
Contributing
If you have any bug fixes / useful feature additions, feel free to fork this repository, make your changes and drop in a pull request.
License
Metadata
Release files for multi-rename 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| multi-rename-0.0.4.tar.gz | 4.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| multi_rename-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.1 kB
Release files / multi-rename-0.0.4.tar.gz
| Download URL | multi-rename-0.0.4.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d0f6893b39082f577875d7e3dcc9a2ae7f30e5bb44113b155218ab0a8266fbc1
|
|
BLAKE2b-256 checksum How to use checksums |
4e945002f61ccd45da37975b604b6e6ada6d59918bee0d73b43be93bb1d22cfe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.7.7
|
Release files / multi_rename-0.0.4-py3-none-any.whl
| Download URL | multi_rename-0.0.4-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cbe42d4303040caef2e9b1a1b81491852b1f276a0c6bba16dde8aa2816591add
|
|
BLAKE2b-256 checksum How to use checksums |
4ba96dde64b59d444a23bb41941f79d8f83d88f89d1990535202cc3a9976884a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.7.7
|