Skip to content

Commit 89c43ca

Browse files
principismebeim
authored andcommitted
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.
1 parent 09e1aee commit 89c43ca

File tree

4 files changed

+81
-2
lines changed

4 files changed

+81
-2
lines changed

pages/linux/file-rename.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# rename
2+
3+
> Rename multiple files.
4+
> NOTE: this page refers to the command from the `file-rename` Debian package.
5+
6+
- Rename files using a Perl Common Regular Expression (substitute 'foo' with 'bar' wherever found):
7+
8+
`rename {{'s/foo/bar/'}} {{*}}`
9+
10+
- Dry-run - display which renames would occur without performing them:
11+
12+
`rename -n {{'s/foo/bar/'}} {{*}}`
13+
14+
- Force renaming even if the operation would remove existing destination files:
15+
16+
`rename -f {{'s/foo/bar/'}} {{*}}`
17+
18+
- Convert filenames to lower case (use `-f` in case-insensitive filesystems to prevent "already exists" errors):
19+
20+
`rename 'y/A-Z/a-z/' {{*}}`
21+
22+
- Replace whitespace with underscores:
23+
24+
`rename 's/\s+/_/g' {{*}}`

pages/linux/perl-rename.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# rename
2+
3+
> Rename multiple files.
4+
> NOTE: this page refers to the command from the `perl-rename` Arch Linux package.
5+
6+
- Rename files using a Perl Common Regular Expression (substitute 'foo' with 'bar' wherever found):
7+
8+
`rename {{'s/foo/bar/'}} {{*}}`
9+
10+
- Dry-run - display which renames would occur without performing them:
11+
12+
`rename -n {{'s/foo/bar/'}} {{*}}`
13+
14+
- Force renaming even if the operation would remove existing destination files:
15+
16+
`rename -f {{'s/foo/bar/'}} {{*}}`
17+
18+
- Convert filenames to lower case (use `-f` in case-insensitive filesystems to prevent "already exists" errors):
19+
20+
`rename 'y/A-Z/a-z/' {{*}}`
21+
22+
- Replace whitespace with underscores:
23+
24+
`rename 's/\s+/_/g' {{*}}`

pages/common/rename.md renamed to pages/linux/prename.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# rename
22

3-
> Renames multiple files.
3+
> Rename multiple files.
4+
> NOTE: this page refers to the command from the `prename` Fedora package.
45
56
- Rename files using a Perl Common Regular Expression (substitute 'foo' with 'bar' wherever found):
67

@@ -10,7 +11,7 @@
1011

1112
`rename -n {{'s/foo/bar/'}} {{*}}`
1213

13-
- Force renaming even if the operation would overwrite existing files:
14+
- Force renaming even if the operation would remove existing destination files:
1415

1516
`rename -f {{'s/foo/bar/'}} {{*}}`
1617

pages/linux/rename.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# rename
2+
3+
> Rename multiple files.
4+
> NOTE: this page refers to the command from the `util-linux` package.
5+
> For the Perl version, see `file-rename` or `perl-rename`.
6+
> Warning: This command has no safeguards and will overwrite files without prompting.
7+
8+
- Rename files using simple substitutions (substitute 'foo' with 'bar' wherever found):
9+
10+
`rename {{foo}} {{bar}} {{*}}`
11+
12+
- Dry-run - display which renames would occur without performing them:
13+
14+
`rename -vn {{foo}} {{bar}} {{*}}`
15+
16+
- Do not overwrite existing files:
17+
18+
`rename -o {{foo}} {{bar}} {{*}}`
19+
20+
- Change file extensions:
21+
22+
`rename {{.ext}} {{.bak}} {{*.ext}}`
23+
24+
- Prepend "foo" to all filenames in the current directory:
25+
26+
`rename {{''}} {{'foo'}} {{*}}`
27+
28+
- Rename a group of increasingly numbered files zero-padding the numbers up to 3 digits:
29+
30+
`rename {{foo}} {{foo00}} {{foo?}} && rename {{foo}} {{foo0}} {{foo??}}`

0 commit comments

Comments
 (0)