ReRenamer is a simple, cross‑platform desktop app for batch renaming files and folders. It supports classic Find/Replace, regular expressions, numbering templates, and parent-folder placeholders. You can keep items AutoSorted or manually reorder them via drag‑and‑drop to create precise sequences.
- GUI: Tkinter (Python standard library)
- Cross‑platform name validation for Windows/macOS/Linux
- Favorites and History for quick reuse
- Multi‑step Undo for safety
- Features
- Requirements
- Installation
- Running
- Usage
- Regex Examples
- OS Notes (Windows/macOS/Linux)
- Configuration and Persistence
- License
- Find/Replace with:
- Regular expressions or literal matching
- Case sensitivity toggle
- Scope: Name only, Extension only, or Name + Extension
- Templates:
- Numbering with zero padding:
<###:start:step>(e.g.,<001:1:1>,<###:10:5>) - Parent folder names:
<p:n>(or legacy<parent:n>), wherenis the depth
- Numbering with zero padding:
- Preview table with color status:
- Gray = unchanged, Green = OK to rename, Red = conflict
- Ordering modes:
- AutoSort (natural sorting, if available)
- Manual reordering by drag‑and‑drop with precise insert indicator
- Batch rename with multi‑step Undo
- Drag & drop to add items (when
tkinterdnd2is installed)
- Python 3.10+ (3.11 recommended)
- Reason: the code uses PEP 604 union types with the
|operator in type hints, which requires Python 3.10 or newer.
- Reason: the code uses PEP 604 union types with the
- Tkinter:
- Windows: included with standard Python from python.org
- macOS: included with python.org installer; with Homebrew Python you may need
brew install tcl-tk - Linux: install system package (e.g.,
sudo apt-get install python3-tk)
- Optional Python modules:
tkinterdnd2for drag & dropnatsortfor natural sorting
- Ensure Python (3.10+) is installed and Tkinter is available (see Requirements).
- Clone or download this repository.
- (Optional) Create and activate a virtual environment:
- macOS/Linux:
python3 -m venv .venv source .venv/bin/activate - Windows (PowerShell):
py -m venv .venv .\.venv\Scripts\Activate.ps1
- macOS/Linux:
- Install optional modules:
pip install tkinterdnd2 natsort
Run the app from the project directory:
python ReRenamer.pyor
python -m ReRenamer- Use buttons:
- “Add Files…”
- “Add Folders…”
- Or drag and drop files/folders into the window (requires
tkinterdnd2)
The app enforces uniform type by default: you cannot mix files and folders in a single batch (to prevent ambiguous renames). You can adjust this behavior in code if needed.
- Case Sensitive: toggles case sensitivity for matching
- Regex: switches between regular expression matching and literal matching
- AutoSort:
- On: keeps the table auto‑sorted (natural sort if
natsortis installed) - Off: preserves your custom order and enables manual drag‑and‑drop reordering
- On: keeps the table auto‑sorted (natural sort if
- Name only: apply Find/Replace to the base name (without the dot and extension)
- Extension only: apply Find/Replace to the extension part
- Name + Extension: treat the entire file name (including extension) as a single string
Notes:
- When “Extension only” is selected, the app normalizes the dot and extension correctly.
- When “Name + Extension” is selected, the app splits the result back into name and extension safely, following OS rules.
- AutoSort ON:
- Items are sorted automatically and continuously.
- Drag‑and‑drop reordering is disabled.
- AutoSort OFF:
- Your table order is preserved.
- Drag‑and‑drop reordering is enabled; use it to create precise sequences (e.g., when building numbered series). A blue horizontal line shows the exact insertion point. Multi‑selection is respected.
- “Apply Rules” performs the actual renaming on disk.
- Conflicts are highlighted in red and must be resolved (invalid names, duplicates, or existing targets).
- “Undo” supports:
- Reverting the latest rename batch
- Restoring recently removed or added items
- Save your current Find/Replace options as a Favorite.
- Quickly recall recent configurations from History (most recent preserved up to a limit).
You can use templates inside the Replace field. Templates are expanded per item during preview/rename.
-
Numbering:
<###:start:step>- Number of
#defines zero‑padding width. startis the initial number (default: 1).stepis the increment (default: 1).- Examples:
- Replace:
photo_<###:1:1>→photo_001,photo_002, … - Replace:
ep-<##:10:5>→ep-10,ep-15,ep-20, …
- Replace:
- Number of
-
Parent folder name:
<p:n>(or<parent:n>)n = 1uses the immediate parent folder’s namen = 2uses the grandparent, etc.- Examples:
- Replace:
<p:1>_#<###:1:1>→Album_#001,Album_#002, … - Replace:
<p:2>-<p:1>_<##>→Project-Album_01, …
- Replace:
You can combine templates with Regex or literal replacement. Templates are expanded before applying numbering increments, and numbering increases only for items where a replacement occurred.
Assume the following sample inputs to illustrate the results.
- Remove a fixed prefix:
- Find (Regex off):
prefix_ - Replace: (empty)
- From:
prefix_report.txt→report.txt
- Swap date order from
YYYY-MM-DDtoDD-MM-YYYY:
- Find (Regex on):
(\d{4})-(\d{2})-(\d{2}) - Replace:
\3-\2-\1 - From:
2023-07-14_notes.txt→14-07-2023_notes.txt
- Keep only digits from a part:
- Scope: Name only
- Find (Regex on):
\D+ - Replace: (empty)
- From:
item-12a-34b→1234
- Change extension from
.jpegor.jpgto.jpgconsistently:
- Scope: Extension only
- Find (Regex on):
jpe?g - Replace:
jpg - From:
image.JPEG→image.jpg(case‑sensitivity depends on the toggle)
- Insert numbering and keep the original name:
- Replace:
<###:1:1>_<p:1>_<p:2>_<###:1:1>
Example result:001_Album_Project_002_filename.ext
Note: numbering increases only where a substitution matched.
- Extract and reorder parts with groups:
- Find (Regex on):
(\w+)-(\d+) - Replace:
\2_\1 - From:
alpha-42.txt→42_alpha.txt
Tips:
- Use
^and$anchors for start/end of the string. - Use lookaheads/lookbehinds for context without capturing, e.g.,
(?<=prefix)_orfoo(?=bar).
- Invalid characters and reserved names:
- Windows: forbids
<>:"/\|?*and control chars; reserved names likeCON,PRN,AUX,NUL,COM1…,LPT1… - Linux/macOS:
/and NUL are invalid in names
- Windows: forbids
- Trailing spaces/dots:
- Not allowed on Windows
- Case sensitivity:
- The app detects duplicates case‑insensitively on Windows/macOS (by default) and case‑sensitively on Linux
- Existing targets:
- Renames that would overwrite existing paths are flagged as conflicts
- Cross‑volume rename:
Path.renamemay fail when moving between different drives/volumes on Windows. If needed, implement a copy‑and‑delete fallback.
- Case‑only renames (e.g.,
file.txt→File.txt) on case‑insensitive file systems can be tricky; the app tries to handle it, but a two‑step rename may be required in some edge cases.
- Config directory:
~/.rerename/favorites.json— saved presets (Find/Replace + options)history.json— recent configurations (newest last)
- These files are written in UTF‑8 JSON.
MIT License. See LICENSE.