1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-29 23:24:55 +02:00

rename: address different versions of the command (#3126)

Address the presence of multiple and different versions of the rename command
as discussed in issue #3125.

Changes made:

- Moved common/rename.md to linux/prename.md, documenting the Debian
  Perl rename command (which is deprecated).
- Created linux/file-rename.md for the Debian/Ubuntu `file-rename`.
- Created linux/perl-rename.md with examples for Arch Linux `perl-rename`.
- Created linux/rename.md for the `rename` command offered by the the
  `util-linux` package, the most common one and supported by the most
  platforms.
This commit is contained in:
Arthur Bols 2019-07-18 14:08:49 +02:00 committed by Marco Bonelli
parent 09e1aeee5b
commit 89c43ca8e4
4 changed files with 81 additions and 2 deletions

View file

@ -0,0 +1,24 @@
# rename
> Rename multiple files.
> NOTE: this page refers to the command from the `file-rename` Debian package.
- 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' {{*}}`

View file

@ -0,0 +1,24 @@
# rename
> Rename multiple files.
> NOTE: this page refers to the command from the `perl-rename` Arch Linux package.
- 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' {{*}}`

View file

@ -1,6 +1,7 @@
# rename # rename
> Renames multiple files. > Rename multiple files.
> NOTE: this page refers to the command from the `prename` Fedora package.
- Rename files using a Perl Common Regular Expression (substitute 'foo' with 'bar' wherever found): - Rename files using a Perl Common Regular Expression (substitute 'foo' with 'bar' wherever found):
@ -10,7 +11,7 @@
`rename -n {{'s/foo/bar/'}} {{*}}` `rename -n {{'s/foo/bar/'}} {{*}}`
- Force renaming even if the operation would overwrite existing files: - Force renaming even if the operation would remove existing destination files:
`rename -f {{'s/foo/bar/'}} {{*}}` `rename -f {{'s/foo/bar/'}} {{*}}`

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

@ -0,0 +1,30 @@
# 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.
- 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 {{foo}} {{bar}} {{*}}`
- Do not overwrite existing files:
`rename -o {{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??}}`