[← README](../../README.md) · [Docs index](../README.md) · [Files](README.md) # Batch rename (Ctrl+M) In the desktop app, **Ctrl+M** renames many files at once with a regular expression and a counter. Every new name is shown before anything changes, and conflicts are caught first. ![Batch rename 12 items with Find (regex) IMG_(\d+) and Replace with Holiday-$1: the list of old and new names, Holiday-0004.jpg marked as a conflict with name already taken, and Rename greyed out](../screenshots/files-batch-rename.png) ## How to use it 1. Mark the entries to rename. With nothing marked, every entry in the folder is taken. 2. Press **Ctrl+M** (or *Batch rename* in the F9 command list). 3. Fill in the fields. The list below updates as you type. 4. Press **Enter** or *Rename*. **Esc** or *Cancel* closes without changing anything. | Field | Does | |---|---| | *Find (regex)* | A regular expression ([Rust syntax](https://docs.rs/regex/latest/regex/#syntax)), e.g. `IMG_(\d+)` | | *Replace with* | The new text: `$1` or `${name}` for groups, `{n}` for the entry's number in the list (from 1), `{n:3}` for the number padded to three digits (`001`), up to 20 | | *Ignore case* | Letters match in either case | | *Replace all matches* | Every match in the name, not only the first | | *Include extension* | Match the whole name; unticked, only the part before the extension is matched and the extension is kept | **Examples:** | Find | Replace with | `IMG_0042.JPG` becomes | |---|---|---| | `IMG_(\d+)` | `Holiday-$1` | `Holiday-0042.JPG` | | `.*` | `rocket-{n:3}` | `rocket-001.JPG` (the numbers follow the list's order) | | `\.JPG$` with *Include extension* | `.jpg` | `IMG_0042.jpg` | | `(\d{4})-(\d{2})-(\d{2})` | `$3.$2.$1` | a date `2026-09-30` in the name becomes `30.09.2026` | | ` ` with *Replace all matches* | `_` | every space becomes `_` | ## What you see - The title says *Batch rename 12 items*. - The list shows every name as `old → new`; names that change are highlighted. A newline, a tab or another control character in a name shows as its picture (`␊`, `␉`, `␛`), so you can see it; a name the pattern does not change is never renamed. Typed in *Find* or *Replace with*, a picture is the character itself: *Find* `␊` and *Replace with* `-` turns the newline in `one␊two.txt` into `one-two.txt`. - A rename that cannot happen is marked red with its reason: `empty name`, `contains a path separator`, `name already taken` (two files getting the same name, or a name taken by a file that is not itself being renamed), or, on Windows, `a name Windows does not allow` (one with `<>:"|?*` in it, one ending in a dot or a space, or a device's name such as `CON` or `nul.txt`). The reasons are in the app's language. - A regular expression that does not parse shows its error in red above the list. - **Rename** stays greyed out while there is a conflict or nothing changes. - A name that appears while the dialog is open (another program saves a file by that name) is never written over: Rename stops with `name already taken`, and nothing is renamed. - Afterwards the status line says `Renamed 12 items` and the pane is read again. Swaps work (`a → b` and `b → a` at once): Coxswain first renames every file to a temporary name, then to its new one. ## Settings and config.toml None. The key is `batch_rename` in `[keys]`. ## In the terminal app Not there: the live list of old and new names needs the desktop app's dialog. **Ctrl+M** in the terminal app says *Batch rename is available in the desktop app (coxswain-gui)*. Rename one file with **F6**, or run a tool such as `rename` or `mmv` on the [command line](../commands/command-line.md). ## Questions #### Why is the Rename button greyed out? A name in the list is red (a conflict), or no name changes. Read the reason next to the red one. #### In which order does `{n}` count? The order of the list, which is the folder's current sort order (marked entries in that order). Sort first (**Ctrl+F3** to **Ctrl+F6**, [Sorting](../panels/sorting.md)) to number by name, extension, date or size. #### Why did `$1_x` not work as I expected? It works: Coxswain reads `$1` followed by `_x`, since people mean group 1. For a named group use `${name}`. #### Why was the extension not changed? With *Include extension* unticked, only the part before the last dot is matched, and the extension is kept. Tick it to match and change the whole name. #### Can I rename files inside an archive with it? No; batch rename works on folders on disk. Inside an archive, rename one entry at a time with **F6** ([Archives as folders](archives.md)). #### What if something fails half-way? Each file is first renamed to a temporary name `.coxswain-rename-…` and then to its new name. If the system refuses a step (a disk removed mid-way), the error is shown in the dialog, and every file gets its old name back, the ones already renamed before the failure too: the batch is done whole, or not at all. A new name that is taken by the time its file gets it (two new names that differ only in case, on a disk that does not mind the case, such as a USB stick or an SMB share) is refused the same way, *name already taken*: no file is ever written over. #### How do I take newlines out of names? The list shows a newline as `␊`. Type `␊` in *Find* (it means the newline) and what should stand there in *Replace with*, tick *Replace all matches*, and press **Enter**. #### Why is `b.txt` a conflict for `a.txt` when only `B.txt` exists? On macOS and Windows the disk does not mind the case: `b.txt` and `B.txt` are one file, and the rename would write over it. On Linux they are two files, and it is no conflict. --- [← Previous: Drag and drop](drag-and-drop.md) · [Next: Find and replace across files (Alt+R) →](find-and-replace.md)