mirror of
https://github.com/ivuorinen/cheatsheet-tldr.git
synced 2026-03-06 14:56:51 +00:00
Update cheatsheets
This commit is contained in:
30
linux/prename
Normal file
30
linux/prename
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
syntax: markdown
|
||||
tags: [tldr, linux]
|
||||
source: https://github.com/tldr-pages/tldr.git
|
||||
---
|
||||
# rename
|
||||
|
||||
> Rename multiple files.
|
||||
> Note: this page refers to the command from the `prename` Fedora package.
|
||||
> More information: <https://manned.org/man/prename>.
|
||||
|
||||
- Rename files using a Perl Common Regular Expression (substitute 'foo' with 'bar' wherever found):
|
||||
|
||||
`rename {{'s/foo/bar/'}} {{*}}`
|
||||
|
||||
- Dry-run - display which renames would occur without performing them:
|
||||
|
||||
`rename -n {{'s/foo/bar/'}} {{*}}`
|
||||
|
||||
- Force renaming even if the operation would remove existing destination files:
|
||||
|
||||
`rename -f {{'s/foo/bar/'}} {{*}}`
|
||||
|
||||
- Convert filenames to lower case (use `-f` in case-insensitive filesystems to prevent "already exists" errors):
|
||||
|
||||
`rename 'y/A-Z/a-z/' {{*}}`
|
||||
|
||||
- Replace whitespace with underscores:
|
||||
|
||||
`rename 's/\s+/_/g' {{*}}`
|
||||
Reference in New Issue
Block a user