1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-08-01 20:35:34 +02:00

rename, file-rename, perl-rename, prename: rework pages (#17259)

Co-authored-by: Managor <42655600+Managor@users.noreply.github.com>
This commit is contained in:
Rubens Altimari 2025-07-26 22:17:25 +02:00 committed by GitHub
parent c3c0cf6ed9
commit 02a086c29a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 86 additions and 108 deletions

View file

@ -0,0 +1,7 @@
# file-rename
> This command is an alias of `rename`.
- View documentation for the original command:
`tldr -p common rename`

View file

@ -0,0 +1,7 @@
# perl-rename
> This command is an alias of `rename`.
- View documentation for the original command:
`tldr -p common rename`

7
pages/common/prename.md Normal file
View file

@ -0,0 +1,7 @@
# prename
> This command is an alias of `rename`.
- View documentation for the original command:
`tldr -p common rename`

30
pages/common/rename.md Normal file
View file

@ -0,0 +1,30 @@
# rename
> Rename a file or group of files with a regular expression.
> WARNING: This command will overwrite files without prompting unless the dry-run option is used.
> Note: This page refers to the Perl version, also known as `file-rename`.
> More information: <https://manned.org/prename>.
- Replace `from` with `to` in the filenames of the specified files:
`rename 's/{{from}}/{{to}}/' {{*.txt}}`
- Dry-run - display which changes would occur without performing them:
`rename -n 's/{{from}}/{{to}}/' {{*.txt}}`
- Change the extension:
`rename 's/\.old$/\.new/' {{*.txt}}`
- Change to lowercase (use `-f` in case-insensitive filesystems):
`rename {{[-f|--force]}} 'y/A-Z/a-z/' {{*.txt}}`
- Capitalize first letter of every word in the name:
`rename {{[-f|--force]}} 's/\b(\w)/\U$1/g' {{*.txt}}`
- Replace spaces with underscores:
`rename 's/\s+/_/g' {{*.txt}}`

View file

@ -1,25 +0,0 @@
# rename
> Rename multiple files.
> Note: This page refers to the command from the `rename` Debian package.
> More information: <https://manned.org/file-rename>.
- Rename files using a Perl Common `regex` (substitute 'foo' with 'bar' wherever found):
`rename {{'s/foo/bar/'}} {{*}}`
- Dry-run - display which renames would occur without performing them:
`rename {{[-n|--nono]}} {{'s/foo/bar/'}} {{*}}`
- Force renaming even if the operation would remove existing destination files:
`rename {{[-f|--force]}} {{'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' {{*}}`

View file

@ -1,25 +0,0 @@
# rename
> Rename multiple files.
> Note: This page refers to the command from the `perl-rename` Arch Linux package.
> More information: <https://manned.org/rename>.
- Rename files using a Perl Common `regex` (substitute 'foo' with 'bar' wherever found):
`rename {{'s/foo/bar/'}} {{*}}`
- Dry-run - display which renames would occur without performing them:
`rename {{[-n|--no-act]}} {{'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' {{*}}`

View file

@ -1,25 +0,0 @@
# rename
> Rename multiple files.
> Note: This page refers to the command from the `prename` Fedora package.
> More information: <https://manned.org/prename>.
- Rename files using a Perl Common `regex` (substitute 'foo' with 'bar' wherever found):
`rename {{'s/foo/bar/'}} {{*}}`
- Dry-run - display which renames would occur without performing them:
`rename {{[-n|--nono]}} {{'s/foo/bar/'}} {{*}}`
- Force renaming even if the operation would remove existing destination files:
`rename {{[-f|--force]}} {{'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' {{*}}`

View file

@ -1,31 +1,11 @@
# rename
> Rename multiple files.
> Note: This page refers to the command from the `util-linux` package.
> For the Perl version, see `file-rename` or `perl-rename`.
> Warning: This command has no safeguards and will overwrite files without prompting.
> More information: <https://manned.org/rename>.
> `rename` can refer to multiple commands with the same name.
- Rename files using simple substitutions (substitute 'foo' with 'bar' wherever found):
- View documentation for the Perl version:
`rename {{foo}} {{bar}} {{*}}`
`tldr -p common rename`
- Dry-run - display which renames would occur without performing them:
- View documentation for the `util-linux` version:
`rename {{[-vn|--verbose --no-act]}} {{foo}} {{bar}} {{*}}`
- Do not overwrite existing files:
`rename {{[-o|--no-overwrite]}} {{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??}}`
`tldr rename.util`

View file

@ -0,0 +1,30 @@
# rename
> Rename multiple files.
> WARNING: This command will overwrite files without prompting unless the dry-run option is used.
> Note: This page refers to the command from the `util-linux` package.
> More information: <https://manned.org/rename>.
- 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|--verbose --no-act]}} {{foo}} {{bar}} {{*}}`
- Do not overwrite existing files:
`rename {{[-o|--no-overwrite]}} {{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??}}`

View file

@ -1,8 +0,0 @@
# rename
> Rename a file or group of files with a `regex`.
> More information: <https://keith.github.io/xcode-man-pages/rename.2.html>.
- Replace `from` with `to` in the filenames of the specified files:
`rename 's/{{from}}/{{to}}/' {{*.txt}}`