Skip to content

CleanCocoa/swift-md-bulk-renamer

Repository files navigation

mvmd

Batch file renamer driven by Markdown tables.

CI

Platforms: macOS, Linux, Windows Requires: Swift 6.2+

Quick Start

git clone https://github.com/CleanCocoa/swift-md-bulk-renamer.git
cd swift-md-bulk-renamer
swift build
swift run mvmd examples/README.md          # preview
swift run mvmd examples/README.md --apply  # execute

See examples/ for demo files.

Installation

git clone https://github.com/CleanCocoa/swift-md-bulk-renamer.git
cd swift-md-bulk-renamer
swift build -c release

The binary will be at .build/release/mvmd.

Usage

Create a Markdown file with a rename table:

| From | To |
|------|-----|
| old-name.txt | new-name.txt |
| report.pdf | 2024-report.pdf |
| src/utils.swift | src/helpers.swift |

Preview what would happen (dry-run):

mvmd renames.md

Execute the renames:

mvmd renames.md --apply

Options

Option Description
--apply Execute renames (default is dry-run)
--force Allow overwriting existing files
-h, --help Show help

Reading from stdin

cat renames.md | mvmd
echo '| From | To |
|---|---|
| a.txt | b.txt |' | mvmd --apply

Or use - explicitly:

mvmd - < renames.md

Table Format

  • First 2-column table in the file is used
  • Header row is required (any names work)
  • Rows with empty "To" column are skipped
  • Paths are relative to the instruction file's directory (not the current working directory)

Safety

mvmd validates all paths before any rename:

  • Rejects absolute paths (/etc/hosts)
  • Rejects parent escapes (../secret.txt)
  • Rejects Windows-style paths on non-Windows platforms (C:\file.txt, \\server\share)
  • Rejects symlinks as sources
  • Prevents overwrites unless --force
  • Detects duplicate sources
  • Detects conflicting destinations

If validation fails, no files are modified.

Exit Codes

Code Meaning
0 Success
1 Error (parsing, validation, or execution failure)

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors