Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

ReChron v2.0

     _____              _____           _____  _____   ______   
 ___|\    \         ___|\    \     ____|\    \|\    \ |\     \  
|    |\    \       |    |\    \   /     /\    \\    \| \     \ 
|    | |    |      |    | |    | /     /  \    \\|    \  \     |
|    |/____/       |    |/____/ |     |    |    ||     \  |    |
|    |\    \       |    |\    \ |     |    |    ||      \ |    |
|    | |    |      |    | |    ||\     \  /    /||    |\ \|    |
|____| |____|      |____| |____|| \_____\/____/ ||____||\_____/|
|    | |    |      |    | |    | \ |    ||    | /|    |/ \|   ||
|____| |____|      |____| |____|  \|____||____|/ |____|   |___|/
  \(     )/          \(     )/       \(    )/      \(       )/  
   '     '            '     '         '    '        '       '
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.


⚠️ Safety Notice

ReChron runs in dry-run mode by default. You must explicitly pass --apply (CLI) or run apply (shell) to execute any rename. All operations are logged to ~/.config/rechron/undo.json and can be reversed with undo.


Features

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.JPEGphoto.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 3001, 40001, etc.

Installation

From Source

git clone https://github.com/Mohamed-bouri/rechron.git
cd rechron
python rechron_v2.0.py --help

Install as CLI Command

pip install -e .

This installs rechron as a system command:

rechron --version

Requirements

  • Python 3.8+ (standard library only — zero external dependencies)

Quick Start

1. Launch the Interactive Shell

rechron
ReChron v2.0 - Chronological Batch File Renamer
By M-Bouri

Type 'help' or '?' to list commands. Type 'exit' to quit.

ReChron>

2. Navigate and List Files

ReChron> cd C:\Users\Admin\Pictures
ReChron> ls
ReChron> ls --ext jpg --sort size --reverse

3. Chronological Rename (Preview)

ReChron> rename --prefix vacation --digits 3 --ext jpg --filter jpeg

Preview 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.

4. Execute the Rename

ReChron> apply

Output:

[+] Renamed 5/5 file(s).

5. Extension-Only Rename

ReChron> ext png --filter bmp --apply

Before: icon.bmp, logo.bmp, photo.bmp
After: icon.png, logo.png, photo.png

6. Undo a Mistake

ReChron> undo

Output:

[+] Restored 5 file(s).

Undo works across sessions — close the shell, come back later, undo still reverses the last batch.


Commands Reference

cd <path>

Change the working directory.

ReChron> cd C:\Users\Admin\Pictures
ReChron> cd D:\Backups\2024
ReChron> cd ~/Photos

pwd

Show current directory.

ReChron> pwd
[*] C:\Users\Admin\Pictures

ls [opts]

List files with optional filtering and sorting.

ReChron> ls
ReChron> ls --ext jpg
ReChron> ls --sort size --reverse
ReChron> ls --ext png --sort name

Options:

  • --ext, -e — Filter by extension
  • --sort, -s — Sort by mtime (default), name, or size
  • --reverse, -r — Reverse order

rename [opts]

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 --apply

Options:

  • --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)

ext <new_extension> [opts]

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 --apply

Before: 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 --filter to avoid collisions. If you have both photo.jpg and photo.eslock, running ext jpg without --filter will try to rename photo.eslockphoto.jpg and collide with the existing photo.jpg.


preview

Show the last generated rename plan without executing.

ReChron> rename --prefix backup --digits 3
ReChron> preview

apply

Execute the last generated rename plan.

ReChron> rename --prefix img --digits 4 --ext jpg
ReChron> apply

undo

Reverse the most recent rename batch.

ReChron> undo

Undo data is stored in ~/.config/rechron/undo.json and persists across sessions.


settings [key] [value]

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: True

Keys: prefix, digits, filter, ext, reverse


clear

Clear the terminal screen.

ReChron> clear

exit / quit

Leave ReChron.

ReChron> exit

Direct CLI Mode

Run 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:\Photos

Exit Codes:

Code Meaning
0 Success
1 Invalid directory or no files matched

Safety Features

Two-Phase Rename

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.

Collision Handling

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.

Dry-Run by Default

Every command previews first. Nothing touches disk until you run apply or pass --apply.


Undo Log Location

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.


Project Structure

rechron/
├── rechron_v2.0.py      # Main application
├── pyproject.toml       # Package configuration
├── requirements.txt     # (empty — stdlib only)
├── README.md            # This file
└── tests/
    └── test_rechron.py

Comparison: ReChron v1 vs v2

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)

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/awesome-feature)
  3. Commit your changes (git commit -m 'Add awesome feature')
  4. Push to the branch (git push origin feature/awesome-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License. See LICENSE for details.


Related Tools

  • PortSpy — Network port & process auditor
  • PyGuard — File integrity monitor with forensic trails
  • HashScout — Advanced duplicate file & video finder

Rename with confidence. Undo with ease.

About

A lightweight, fast, and safe CLI tool to batch-rename files chronologically by date, with zero-padding and file extension conversion

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages