2019-07-18 13:08:49 +01:00
|
|
|
# rename
|
|
|
|
|
|
|
|
> Rename multiple files.
|
2024-02-05 07:04:49 +00:00
|
|
|
> Note: this page refers to the command from the `util-linux` package.
|
2019-07-18 13:08:49 +01:00
|
|
|
> For the Perl version, see `file-rename` or `perl-rename`.
|
|
|
|
> Warning: This command has no safeguards and will overwrite files without prompting.
|
2022-03-21 17:07:48 +00:00
|
|
|
> More information: <https://manned.org/rename>.
|
2019-07-18 13:08:49 +01:00
|
|
|
|
|
|
|
- Rename files using simple substitutions (substitute 'foo' with 'bar' wherever found):
|
|
|
|
|
|
|
|
`rename {{foo}} {{bar}} {{*}}`
|
|
|
|
|
|
|
|
- Dry-run - display which renames would occur without performing them:
|
|
|
|
|
|
|
|
`rename -vn {{foo}} {{bar}} {{*}}`
|
|
|
|
|
|
|
|
- Do not overwrite existing files:
|
|
|
|
|
|
|
|
`rename -o {{foo}} {{bar}} {{*}}`
|
|
|
|
|
|
|
|
- Change file extensions:
|
|
|
|
|
|
|
|
`rename {{.ext}} {{.bak}} {{*.ext}}`
|
|
|
|
|
|
|
|
- Prepend "foo" to all filenames in the current directory:
|
|
|
|
|
|
|
|
`rename {{''}} {{'foo'}} {{*}}`
|
|
|
|
|
|
|
|
- Rename a group of increasingly numbered files zero-padding the numbers up to 3 digits:
|
|
|
|
|
|
|
|
`rename {{foo}} {{foo00}} {{foo?}} && rename {{foo}} {{foo0}} {{foo??}}`
|