Skip to main content

Bulk rename files based on a pattern

Project description

Bulk Rename

A CLI utility for bulk renaming files based on a pattern.

PyPI version

Installation

Install via pip:

pip install bulk-rename-signalsenryu

Or install via uv:

uv pip install bulk-rename-signalsenryu

Usage

After installation:

bulk-rename --help

Or run without installing:

# Using Python module
python -m bulk_rename --help

# Using uv run (from project directory)
uv run bulk-rename --help

# Using uvx (runs directly without installation)
uvx bulk-rename-signalsenryu --help

Available Options

-d, --path PATH        Directory containing files to rename (required)
-p, --pattern PATTERN  Naming pattern, e.g., "video_{:03d}" (required)
-e, --extension EXT    File extension to filter, e.g., "mp4" (required)
-s, --start NUM        Starting index for numbering (default: 1)
--version              Show version and exit

Examples

Basic Usage

Suppose you have a directory with video files:

ls videos/
a.mp4  b.mp4  c.mp4

Rename them with zero-padded numbering:

bulk-rename -d ./videos -p "video_{:03d}" -e mp4

Or with uvx:

uvx bulk-rename -d ./videos -p "video_{:03d}" -e mp4

Preview and confirm:

✅ videos/a.mp4 -> videos/video_001.mp4
✅ videos/b.mp4 -> videos/video_002.mp4
✅ videos/c.mp4 -> videos/video_003.mp4
Proceed? (y/n): y

Result:

ls videos/
backup_2026-01-20_08-48-13.txt  video_001.mp4  video_002.mp4  video_003.mp4

A backup file is automatically created:

cat videos/backup_2026-01-20_08-48-13.txt
videos/a.mp4 -> videos/video_001.mp4
videos/b.mp4 -> videos/video_002.mp4
videos/c.mp4 -> videos/video_003.mp4

Custom Starting Index

Start numbering from 10:

bulk-rename -d ./photos -p "IMG_{:02d}" -e jpg -s 10

Result:

photos/x.jpg -> photos/IMG_10.jpg
photos/y.jpg -> photos/IMG_11.jpg
photos/z.jpg -> photos/IMG_12.jpg

Handling Conflicts

If target files already exist, the tool detects conflicts:

❌ videos/video_001.mp4 -> videos/video_001.mp4 [Target file already exists]
Found 1 conflict
Continue with skipping conflicts? (y/n): n

Features

  • ✅ Preview changes before applying
  • ✅ Automatic conflict detection
  • ✅ Asks for confirmation before renaming
  • ✅ Backup file creation with timestamps
  • ✅ Alphabetical sorting of source files
  • ✅ Customizable numbering patterns

Development

Setup

Clone the repository and install in editable mode:

Using pip:

git clone https://github.com/signalsenryu/bulk-rename.git
cd bulk-rename
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -e ".[dev]"

Using uv:

git clone https://github.com/signalsenryu/bulk-rename.git
cd bulk-rename
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
uv pip install -e ".[dev]"

Or even simpler with uv sync:

git clone https://github.com/signalsenryu/bulk-rename.git
cd bulk-rename
uv sync --extra dev

Run Tests

Using pip:

pytest tests/ -vv -s --cov=. --cov-report=term-missing

Using uv:

uv run pytest tests/ -vv -s --cov=. --cov-report=term-missing

Project Structure

bulk-rename/
├── src/
│   └── bulk_rename/
│       ├── __init__.py
│       ├── __main__.py
│       └── cli.py
├── tests/
│   └── test_renamer.py
├── pyproject.toml
└── README.md

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bulk_rename_signalsenryu-0.1.1.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bulk_rename_signalsenryu-0.1.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file bulk_rename_signalsenryu-0.1.1.tar.gz.

File metadata

File hashes

Hashes for bulk_rename_signalsenryu-0.1.1.tar.gz
Algorithm Hash digest
SHA256 565804738087c95dc2a3e69f24996d49d10d676a98b606134a5dde4294751b40
MD5 93e8015a8bc14c8bacf5c3dbee69cc24
BLAKE2b-256 70e7fb88414bd0df752c7207436e96be9742f30222344e9701ae586a8c1cf90a

See more details on using hashes here.

File details

Details for the file bulk_rename_signalsenryu-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bulk_rename_signalsenryu-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b76dc21e5782859c5d765303bc52b4d23a1857fd623649cb9243bc8092c80393
MD5 7bf7e5794bb18b6022ebafa3c2bb8071
BLAKE2b-256 fa129d0fef576289228b9b04d63752cd816501f914366f4b9e34509d24241036

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page