-
Couldn't load subscription status.
- Fork 2
Bulk Change File Extensions
bulk-change-ext is a utility script to batch-rename file extensions (e.g., .png β .jpg) without modifying file contents.
It is generic, safe, and supports dry-run preview, recursive processing, and conflict handling.
-
π Rename any extension (not just
.png β .jpg) -
π Optional recursive mode (
-r) to include subfolders -
π Dry-run mode to preview changes without touching files
-
π Safe conflict handling: skip by default, or overwrite with
--overwrite -
π Case-insensitive by default, with opt-in case-sensitive matching
-
β Deterministic order for reproducible results
poetry run bulk-change-ext ./assets/illustrations --from .png --to .jpgpoetry run bulk-change-ext ./images --from png --to jpg -r --dry-run
#### Overwrite conflicts and use case-sensitive match
poetry run bulk-change-ext ./photos --from .PNG --to .jpeg --case-sensitive --overwritepoetry run bulk-change-ext ./photos --from .PNG --to .jpeg --case-sensitive --overwrite| Option | Description |
|---|---|
directory |
Target directory to process |
--from EXT |
Source extension (with/without dot) |
--to EXT |
Destination extension (with/without dot) |
-r, --recursive |
Recurse into subdirectories |
--case-sensitive |
Match extensions case-sensitively (default = insensitive) |
--dry-run |
Show what would be changed, but do nothing |
--overwrite |
Overwrite destination if it exists (default = skip) |
# Dry-run to preview
bulk-change-ext ./assets --from txt --to md --dry-run
# Actual rename
bulk-change-ext ./assets --from txt --to md| Scenario | Test(s) |
|---|---|
Happy path (.png β .jpg) |
test_happy_path_png_to_jpg |
| Case-sensitive vs insensitive | test_case_sensitive_only_exact_match |
| Recursive processing | test_recursive_subdirs |
| Conflict handling (skip) | test_conflict_skips_when_overwrite_false |
| Conflict handling (overwrite) | test_conflict_overwrite_true |
| Dry-run behavior | test_dry_run_does_not_change_files |
| Missing directory | test_directory_does_not_exist_is_error |
| CLI smoke test | test_cli_smoke |
- π Home
- Project Initialization
- Generate Project Structure
- How to Write a Book
- Developer Workflow & Makefile
- Chapter File Generator
- Generate Images
- Convert Markdown Images
- Bulk Change File Extensions
- Restructure Chapters
- Translate Markdown with DeepL
- Translate with LM Studio
- Translation CLI Commands
- Shortcuts for Translation
- Automatic Book Export
- Shortcuts for Export
- Export HTML Chapters (Comics)
- Export to EPUB 2
- Pandoc Batch Processor
- Export HTML Books to PDF (KDP Ready)
Use this sidebar to navigate all key workflows β from setup to translation, export, and testing.