2014-02-23 21:08:04 +04:00
|
|
|
# rename
|
|
|
|
|
2016-01-07 20:31:27 +03:00
|
|
|
> Renames multiple files.
|
2014-02-23 21:08:04 +04:00
|
|
|
|
2016-01-20 14:41:12 +03:00
|
|
|
- Rename files using a Perl Common Regular Expression (substitute 'foo' with 'bar' wherever found):
|
2014-02-23 21:08:04 +04:00
|
|
|
|
2019-03-27 02:49:14 +03:00
|
|
|
`rename {{'s/foo/bar/'}} {{*}}`
|
2014-02-23 21:08:04 +04:00
|
|
|
|
2016-01-20 20:59:42 +03:00
|
|
|
- Dry-run - display which renames would occur without performing them:
|
2014-02-23 21:08:04 +04:00
|
|
|
|
2019-03-27 02:49:14 +03:00
|
|
|
`rename -n {{'s/foo/bar/'}} {{*}}`
|
2014-02-23 21:08:04 +04:00
|
|
|
|
2016-07-20 08:47:32 +03:00
|
|
|
- Force renaming even if the operation would overwrite existing files:
|
|
|
|
|
2019-03-27 02:49:14 +03:00
|
|
|
`rename -f {{'s/foo/bar/'}} {{*}}`
|
2016-07-20 08:47:32 +03:00
|
|
|
|
|
|
|
- Convert filenames to lower case (use `-f` in case-insensitive filesystems to prevent "already exists" errors):
|
2014-02-23 21:08:04 +04:00
|
|
|
|
2019-03-27 02:49:14 +03:00
|
|
|
`rename 'y/A-Z/a-z/' {{*}}`
|
2015-06-26 05:35:13 +03:00
|
|
|
|
2016-01-20 14:41:12 +03:00
|
|
|
- Replace whitespace with underscores:
|
2015-06-26 05:35:13 +03:00
|
|
|
|
2019-03-27 02:49:14 +03:00
|
|
|
`rename 's/\s+/_/g' {{*}}`
|