Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions pages/linux/file-rename.md
Original file line number Diff line number Diff line change
@@ -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' {{*}}`
24 changes: 24 additions & 0 deletions pages/linux/perl-rename.md
Original file line number Diff line number Diff line change
@@ -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' {{*}}`
5 changes: 3 additions & 2 deletions pages/common/rename.md → pages/linux/prename.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 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):

Expand All @@ -10,7 +11,7 @@

`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/'}} {{*}}`

Expand Down
30 changes: 30 additions & 0 deletions pages/linux/rename.md
Original file line number Diff line number Diff line change
@@ -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 'foo1', ..., 'foo10', ..., 'foo100' to 'foo001', ..., 'foo010', ..., 'foo100':

`rename {{foo}} {{foo00}} {{foo?}} && rename {{foo}} {{foo0}} {{foo??}}`