2013-10-14 02:36:58 +00:00
|
|
|
---
|
2013-01-08 08:37:25 +00:00
|
|
|
title: rename
|
2015-11-24 05:11:34 +00:00
|
|
|
category: CLI
|
2013-01-08 08:37:25 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
### Installation
|
|
|
|
|
2017-10-16 06:41:14 +00:00
|
|
|
```bash
|
|
|
|
brew install rename
|
|
|
|
```
|
2013-01-08 08:37:25 +00:00
|
|
|
|
2017-10-16 06:41:14 +00:00
|
|
|
See: <http://plasmasturm.org/code/rename/>
|
2013-01-08 08:37:25 +00:00
|
|
|
|
2017-10-16 06:41:14 +00:00
|
|
|
### Regex substitution
|
2013-01-08 08:37:25 +00:00
|
|
|
|
2017-10-16 06:41:14 +00:00
|
|
|
```bash
|
|
|
|
rename 's/hello/world/' *.txt
|
|
|
|
```
|
|
|
|
|
|
|
|
Rename `hello.txt` to `world.txt` and so on in `*.txt`.
|
|
|
|
|
|
|
|
### Replace extension
|
|
|
|
|
|
|
|
```bash
|
|
|
|
rename -s .png .jpg.png *.png
|
|
|
|
```
|
|
|
|
|
|
|
|
Replace `.png` with `.jpg.png` in `*.png`.
|
2013-01-08 08:37:25 +00:00
|
|
|
|
|
|
|
### Options
|
|
|
|
|
2018-03-03 00:07:10 +00:00
|
|
|
| Option | Description |
|
|
|
|
| --- | --- |
|
|
|
|
| `-n` | Simulation |
|
|
|
|
| `-l` | Symlink instead of rename |
|
|
|
|
| `-i` | Interactive |
|
2017-10-16 06:41:14 +00:00
|
|
|
|
|
|
|
## Also see
|
|
|
|
|
|
|
|
- [Rename website](http://plasmasturm.org/code/rename/) _(plasmasturm.org)_
|