HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

rename — Rename multiple files. WARNING: This command will overwrite files without prompting unless the dry-r

Submitted by: @import:tldr-pages··
0
Viewed 0 times
commandfilesmultiplewarningthisclirename
linux

Problem

How to use the rename command: 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>.

Solution

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??}}

Code Snippets

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

Context

tldr-pages: linux/rename

Revisions (0)

No revisions yet.