2014-02-23 12:08:04 -05:00
|
|
|
# rename
|
|
|
|
|
2019-07-18 14:08:49 +02:00
|
|
|
> Rename multiple files.
|
2024-02-05 12:34:49 +05:30
|
|
|
> Note: this page refers to the command from the `perl-rename` Arch Linux package.
|
2022-03-22 03:07:48 +10:00
|
|
|
> More information: <https://manned.org/rename>.
|
2014-02-23 12:08:04 -05:00
|
|
|
|
2016-01-20 03:41:12 -08:00
|
|
|
- Rename files using a Perl Common Regular Expression (substitute 'foo' with 'bar' wherever found):
|
2014-02-23 12:08:04 -05:00
|
|
|
|
2019-03-26 18:49:14 -05:00
|
|
|
`rename {{'s/foo/bar/'}} {{*}}`
|
2014-02-23 12:08:04 -05:00
|
|
|
|
2016-01-20 09:59:42 -08:00
|
|
|
- Dry-run - display which renames would occur without performing them:
|
2014-02-23 12:08:04 -05:00
|
|
|
|
2025-04-20 00:21:53 +03:00
|
|
|
`rename {{[-n|--no-act]}} {{'s/foo/bar/'}} {{*}}`
|
2014-02-23 12:08:04 -05:00
|
|
|
|
2019-07-18 14:08:49 +02:00
|
|
|
- Force renaming even if the operation would remove existing destination files:
|
2016-07-20 06:47:32 +01:00
|
|
|
|
2019-03-26 18:49:14 -05:00
|
|
|
`rename -f {{'s/foo/bar/'}} {{*}}`
|
2016-07-20 06:47:32 +01:00
|
|
|
|
|
|
|
- Convert filenames to lower case (use `-f` in case-insensitive filesystems to prevent "already exists" errors):
|
2014-02-23 12:08:04 -05:00
|
|
|
|
2019-03-26 18:49:14 -05:00
|
|
|
`rename 'y/A-Z/a-z/' {{*}}`
|
2015-06-25 22:35:13 -04:00
|
|
|
|
2016-01-20 03:41:12 -08:00
|
|
|
- Replace whitespace with underscores:
|
2015-06-25 22:35:13 -04:00
|
|
|
|
2019-03-26 18:49:14 -05:00
|
|
|
`rename 's/\s+/_/g' {{*}}`
|