2014-02-23 12:08:04 -05:00
|
|
|
# rename
|
|
|
|
|
2016-01-07 18:31:27 +01:00
|
|
|
> Renames multiple files.
|
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
|
|
|
|
2016-01-20 03:41:12 -08: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
|
|
|
|
2016-01-20 03:41:12 -08:00
|
|
|
`rename -n {{'s/foo/bar/'}} {{\*}}`
|
2014-02-23 12:08:04 -05:00
|
|
|
|
2016-07-20 06:47:32 +01:00
|
|
|
- Force renaming even if the operation would overwrite existing files:
|
|
|
|
|
|
|
|
`rename -f {{'s/foo/bar/'}} {{\*}}`
|
|
|
|
|
|
|
|
- Convert filenames to lower case (use `-f` in case-insensitive filesystems to prevent "already exists" errors):
|
2014-02-23 12:08:04 -05:00
|
|
|
|
2016-01-20 03:41:12 -08: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
|
|
|
|
2016-01-20 03:41:12 -08:00
|
|
|
`rename 's/\s+/_/g' {{\*}}`
|