RenPy is a Python library and CLI tool designed to automate file renaming in a given directory. It sequentially renames files using a specified base name, appending a numeric index while preserving the original file extension.
Feature | Availability | Description |
---|---|---|
Batch Rename | β | Rename multiple files at once with a custom prefix. |
Sorting Options | β | Rename files in alphabetical, newest, or oldest order. |
Simulation Mode | β | Preview renaming changes without modifying files. No actual changes are made. |
Library Support | β | Use RenPy as a module in your Python scripts for automation. |
Cross-Platform | β | Works seamlessly on Windows, macOS, and Linux. |
- Python 3.x installed
- Basic knowledge of command-line usage
RenPy requires the following package(s):
pyfiglet
(for CLI banner text)
To install dependencies, run:
pip install -r requirements.txt # Use pip3 on macOS
To install RenPy as a library:
pip install renpy
To install and run the tool from the source code:
(git clone https://github.com/MFM-347/Ren.py.git
cd Ren.py
pip install .
renpy <base_name> <directory> [-r <order>] [-s]
Rename files inside C:\Users\YourName\Documents\Folder
, using "File" as the base name:
renpy "File" C:\Users\YourName\Documents\Folder
report.docx
notes.txt
summary.pdf
renpy "Document" C:\Docs -r alphabet
Document-1.docx
Document-2.pdf
Document-3.txt
Option | Description |
---|---|
<base_name> |
Prefix for renamed files. |
<directory> |
Path to folder containing the files. |
-r, --order <order> |
Sorting order before renaming: |
- alphabet β A-Z order |
|
- new β Newest to oldest |
|
- old β Oldest to newest (default) |
|
-s, --simulate |
Run a simulation without renaming files. |
--case-sensitive |
Sorts filenames in case-sensitive mode. |
--debug |
Enables debug logging. |
If you have installed RenPy via pip
, you can use it in your Python scripts as follows:
from renpy import renFn
from pathlib import Path
directory = Path("C:/Users/YourName/Documents/Folder")
renFn(base_name="Document", directory=directory, order="alphabet", simulate=False, case_sensitive=False)
If running directly from the cloned source repository:
from renpy import renFn
from pathlib import Path
directory = Path("C:/Users/YourName/Documents/Folder")
renFn(base_name="Document", directory=directory, order="alphabet", simulate=False, case_sensitive=False)
If you only need to get sorted files without renaming:
from renpy import sortFn
from pathlib import Path
directory = Path("/path/to/files")
sorted_files = sortFn(directory, order="new", case_sensitive=True)
print(sorted_files)
You can wrap it in a try-except block:
try:
renFn("Example", Path("/home/user/files"), "old", False, False)
except Exception as e:
print(f"An error occurred: {e}")
Run all tests:
python -m unittest discover tests
- Add option to rename only specific file type.
- Add Graphic User Interface (GUI).
We welcome contributions! Please check the CONTRIBUTING.md for guidelines.
Created and maintained by MFM-347.
This project is licensed under the MIT License.