_____ _____ _____ _____ ______
___|\ \ ___|\ \ ____|\ \|\ \ |\ \
| |\ \ | |\ \ / /\ \\ \| \ \
| | | | | | | | / / \ \\| \ \ |
| |/____/ | |/____/ | | | || \ | |
| |\ \ | |\ \ | | | || \ | |
| | | | | | | ||\ \ / /|| |\ \| |
|____| |____| |____| |____|| \_____\/____/ ||____||\_____/|
| | | | | | | | \ | || | /| |/ \| ||
|____| |____| |____| |____| \|____||____|/ |____| |___|/
\( )/ \( )/ \( )/ \( )/
' ' ' ' ' ' ' '
Chronological Batch File Renamer with Interactive Shell by M-Bouri
Chronological Batch File Renamer with Interactive Shell
ReChron sorts files by date and renames them sequentially — or swaps extensions while preserving original names. Features a persistent undo log, two-phase collision-safe renaming, and an interactive shell for rapid iteration without relaunching.
ReChron runs in dry-run mode by default. You must explicitly pass
--apply(CLI) or runapply(shell) to execute any rename. All operations are logged to~/.config/rechron/undo.jsonand can be reversed withundo.
| Feature | Description |
|---|---|
| Chronological Rename | Sort by modification time and rename to prefix_001.ext, prefix_002.ext... |
| Extension-Only Mode | Change extensions while keeping original base names (photo.JPEG → photo.jpg) |
| Interactive Shell | ReChron> prompt — cd, preview, tweak settings, and re-run without relaunching |
| Two-Phase Safe Rename | Stages files to temp names first, then moves to final names — prevents collision cascades |
| Persistent Undo | Reverse any rename batch across sessions via ~/.config/rechron/undo.json |
| Dry-Run by Default | Preview every change before executing |
| Smart Collision Handling | Skips instead of overwriting when target exists; leaves temp file for manual recovery |
| Filter by Extension | Target only .jpg, .png, .mp4, etc. |
| Multi-Sort Listing | List files sorted by mtime, name, or size |
| Reverse Order | Rename newest-first instead of oldest-first |
| Custom Zero-Padding | 3 → 001, 4 → 0001, etc. |
git clone https://github.com/Mohamed-bouri/rechron.git
cd rechron
python rechron_v2.0.py --helppip install -e .This installs rechron as a system command:
rechron --version- Python 3.8+ (standard library only — zero external dependencies)
rechronReChron v2.0 - Chronological Batch File Renamer
By M-Bouri
Type 'help' or '?' to list commands. Type 'exit' to quit.
ReChron>
ReChron> cd C:\Users\Admin\Pictures
ReChron> ls
ReChron> ls --ext jpg --sort size --reverseReChron> rename --prefix vacation --digits 3 --ext jpg --filter jpegPreview Output:
Directory: C:\Users\Admin\Pictures
Files: 5
---------------------------------------------------------------------------
[2023-05-09 10:40:21] DSC_001.jpeg --> vacation_001.jpg
[2023-05-10 14:22:07] DSC_002.jpeg --> vacation_002.jpg
[2023-05-11 09:15:33] IMG_4521.jpeg --> vacation_003.jpg
[2023-05-12 18:47:12] photo_backup.jpeg --> vacation_004.jpg
[2023-05-13 11:03:59] final_edit.jpeg --> vacation_005.jpg
---------------------------------------------------------------------------
[+] Use 'apply' to execute, or tweak settings and 'preview' again.
ReChron> applyOutput:
[+] Renamed 5/5 file(s).
ReChron> ext png --filter bmp --applyBefore: icon.bmp, logo.bmp, photo.bmp
After: icon.png, logo.png, photo.png
ReChron> undoOutput:
[+] Restored 5 file(s).
Undo works across sessions — close the shell, come back later, undo still reverses the last batch.
Change the working directory.
ReChron> cd C:\Users\Admin\Pictures
ReChron> cd D:\Backups\2024
ReChron> cd ~/PhotosShow current directory.
ReChron> pwd
[*] C:\Users\Admin\PicturesList files with optional filtering and sorting.
ReChron> ls
ReChron> ls --ext jpg
ReChron> ls --sort size --reverse
ReChron> ls --ext png --sort nameOptions:
--ext, -e— Filter by extension--sort, -s— Sort bymtime(default),name, orsize--reverse, -r— Reverse order
Generate a chronological rename plan (prefix_001.ext, prefix_002.ext...).
ReChron> rename
ReChron> rename --prefix photo --digits 4
ReChron> rename --prefix vid --filter mp4 --reverse --apply
ReChron> rename --prefix img --ext jpg --filter jpeg --applyOptions:
--prefix, -p— Base name (default:file)--digits, -d— Zero-padding length (default:3)--ext, -e— Force new extension (e.g.,jpg)--filter, -f— Only process files with this extension--reverse, -r— Newest first instead of oldest first--apply, -a— Execute immediately (default is preview-only)
Extension-only rename — keeps original file names, only changes the extension.
ReChron> ext jpg
ReChron> ext png --filter bmp --apply
ReChron> ext mp4 --filter avi --applyBefore: photo.JPEG, icon.BMP, movie.AVI
After: photo.jpg, icon.png, movie.mp4
Options:
--filter, -f— Only process files with this extension--apply, -a— Execute immediately
Tip: Use
--filterto avoid collisions. If you have bothphoto.jpgandphoto.eslock, runningext jpgwithout--filterwill try to renamephoto.eslock→photo.jpgand collide with the existingphoto.jpg.
Show the last generated rename plan without executing.
ReChron> rename --prefix backup --digits 3
ReChron> previewExecute the last generated rename plan.
ReChron> rename --prefix img --digits 4 --ext jpg
ReChron> applyReverse the most recent rename batch.
ReChron> undoUndo data is stored in ~/.config/rechron/undo.json and persists across sessions.
View or change default settings.
ReChron> settings
[*] Current defaults:
prefix : file
digits : 3
filter : (none)
ext : (keep original)
reverse : False
ReChron> settings prefix photo
[+] Default prefix set to: photo
ReChron> settings digits 4
[+] Default digits set to: 4
ReChron> settings filter jpg
[+] Default filter set to: jpg
ReChron> settings reverse true
[+] Default reverse set to: TrueKeys: prefix, digits, filter, ext, reverse
Clear the terminal screen.
ReChron> clearLeave ReChron.
ReChron> exitRun commands without entering the shell:
# Chronological rename
rechron rename C:\Photos --prefix img --digits 4 --ext jpg --filter jpeg --apply
# Extension-only rename
rechron ext C:\Photos png --filter bmp --apply
# List files
rechron ls C:\Photos --ext jpg --sort size
# Undo last batch
rechron undo C:\PhotosExit Codes:
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Invalid directory or no files matched |
ReChron never renames directly. It uses a staging process:
Phase 1: photo.jpg → .rechron_tmp_a1b2c3d4_photo.jpg
Phase 2: .rechron_tmp_a1b2c3d4_photo.jpg → vacation_001.jpg
This prevents the classic batch-rename bug where renaming file A onto file B's path causes later files to read wrong metadata or overwrite each other.
If the target name already exists, ReChron skips instead of overwriting:
[!] SKIP photo.eslock: target 'photo.jpg' already exists.
Left as temp: .rechron_tmp_a1b2c3d4_photo.eslock
The original file is preserved under its temp name. You can manually resolve the conflict and delete the temp.
Every command previews first. Nothing touches disk until you run apply or pass --apply.
Windows: C:\Users\<You>\.config\rechron\undo.json
Linux: ~/.config/rechron/undo.json
macOS: ~/.config/rechron/undo.json
The log stores the last 50 rename batches. Old entries auto-prune to prevent bloat.
rechron/
├── rechron_v2.0.py # Main application
├── pyproject.toml # Package configuration
├── requirements.txt # (empty — stdlib only)
├── README.md # This file
└── tests/
└── test_rechron.py
| Capability | v1.0 | v2.0 |
|---|---|---|
| Chronological rename | ✅ | ✅ |
| Two-phase safe rename | ✅ | ✅ |
| Interactive shell | ❌ | ✅ |
| Extension-only mode | ❌ | ✅ |
| Persistent undo | ❌ | ✅ |
| Settings persistence | ❌ | ✅ |
| File listing with sort | ❌ | ✅ |
| Dry-run by default | ✅ | ✅ |
| Collision skip (no overwrite) | ✅ | ✅ |
- Fork the repository
- Create a feature branch (
git checkout -b feature/awesome-feature) - Commit your changes (
git commit -m 'Add awesome feature') - Push to the branch (
git push origin feature/awesome-feature) - Open a Pull Request
This project is licensed under the MIT License. See LICENSE for details.
- PortSpy — Network port & process auditor
- PyGuard — File integrity monitor with forensic trails
- HashScout — Advanced duplicate file & video finder
Rename with confidence. Undo with ease.