Rename multiple files with a pattern
high risk
rename -n 's/old/new/' *.txtDry run firstRenames files using a Perl regex (Debian/Ubuntu) or a simple string substitution (util-linux). Syntax differs between implementations.
| Flag | Meaning |
|---|---|
-n | Dry run: show what would be renamed (Perl rename) |
-v | Verbose |
-f | Force overwriting existing files |
rename -n 's/\.jpeg$/.jpg/' *.jpegPreview renaming .jpeg to .jpg · explain & risk-check →rename 's/ /_/g' *Replace spaces with underscores · explain & risk-check →Reference text is hand-written and may be incomplete — check man rename for your version. Test destructive commands on a non-production system first.