{"id":411,"date":"2011-02-02T04:43:16","date_gmt":"2011-02-02T10:43:16","guid":{"rendered":"http:\/\/blog.supportpro.com\/2011\/02\/rename-command\/"},"modified":"2026-03-27T00:07:14","modified_gmt":"2026-03-27T06:07:14","slug":"rename-command","status":"publish","type":"post","link":"https:\/\/www.supportpro.com\/blog\/rename-command\/","title":{"rendered":"How to Rename Multiple Files Using the Linux Rename Command"},"content":{"rendered":"\n<p>The <strong>rename<\/strong> command is a Perl-based utility in Linux used to rename single or multiple files quickly using pattern matching. It is especially useful when you need to modify filenames in bulk.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>General Syntax<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>rename &#91; -v ] &#91; -n ] &#91; -f ] perlexpr &#91; files ]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Options Explained<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>-v<\/strong> \u2014 Verbose mode. Displays renamed files.<\/li>\n\n\n\n<li><strong>-n<\/strong> \u2014 Test mode. Shows the expected result without making changes.<\/li>\n\n\n\n<li><strong>perlexpr<\/strong> \u2014 A Perl expression used to define the rename rule.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Example Command<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>rename -n 's\/\\.htm$\/\\.html\/' *.htm<\/code><\/pre>\n\n\n\n<p>The <strong>-n<\/strong> option performs a dry run and displays how files will be renamed without actually modifying them.<\/p>\n\n\n\n<p>If the output looks correct, run the final command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rename -v 's\/\\.htm$\/\\.html\/' *.htm<\/code><\/pre>\n\n\n\n<p>This command renames all files ending with <code>.htm<\/code> to <code>.html<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Command Breakdown<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>s<\/strong> \u2192 Substitute operation.<\/li>\n\n\n\n<li><strong>s\/old\/new\/<\/strong> \u2192 Replaces <em>old<\/em> text with <em>new<\/em> text.<\/li>\n\n\n\n<li><strong>.<\/strong> \u2192 Escapes the period (<code>.<\/code>) so it is treated as a normal character.<\/li>\n\n\n\n<li><strong>.htm$<\/strong> \u2192 Matches filenames ending exactly with <code>.htm<\/code>.<\/li>\n\n\n\n<li><strong>$<\/strong> \u2192 Indicates the end of the filename.<\/li>\n\n\n\n<li><strong>*<\/strong> \u2192 Wildcard selecting all <code>.htm<\/code> files.<\/li>\n<\/ul>\n\n\n\n<p>Using the rename command simplifies bulk file management and reduces manual work in Linux environments.<\/p>\n\n\n\n<p>If you require help, <a href=\"https:\/\/www.supportpro.com\/requestquote.php\">contact SupportPRO Server Admin<\/a><span id=\"hs-cta-wrapper-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-wrapper\"><span id=\"hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-node hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\"><a href=\"https:\/\/www.supportpro.com\/freecheckup.php\"><\/a><\/span><\/span><\/p>\n\n\n\n<div class=\"wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile is-vertically-aligned-center has-white-background-color has-background\"><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\">Facing issues? <\/p>\n\n\n\n<p class=\"has-large-font-size\">Our technical support<br>engineers can solve it. <\/p>\n\n\n\n<!--HubSpot Call-to-Action Code --><span class=\"hs-cta-wrapper\" id=\"hs-cta-wrapper-3350a795-db50-482f-9911-301930d1b1be\"><span class=\"hs-cta-node hs-cta-3350a795-db50-482f-9911-301930d1b1be\" id=\"hs-cta-3350a795-db50-482f-9911-301930d1b1be\"><!--[if lte IE 8]><div id=\"hs-cta-ie-element\"><\/div><![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/3350a795-db50-482f-9911-301930d1b1be\" ><img decoding=\"async\" class=\"hs-cta-img\" id=\"hs-cta-img-3350a795-db50-482f-9911-301930d1b1be\" style=\"border-width:0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/3350a795-db50-482f-9911-301930d1b1be.png\"  alt=\"Contact Us today!\"\/><\/a><\/span><script charset=\"utf-8\" src=\"https:\/\/js.hscta.net\/cta\/current.js\"><\/script><script type=\"text\/javascript\"> hbspt.cta.load(2725694, '3350a795-db50-482f-9911-301930d1b1be', {\"useNewLoader\":\"true\",\"region\":\"na1\"}); <\/script><\/span><!-- end HubSpot Call-to-Action Code -->\n<\/div><figure class=\"wp-block-media-text__media\"><img fetchpriority=\"high\" decoding=\"async\" width=\"904\" height=\"931\" src=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png\" alt=\"guy server checkup\" class=\"wp-image-12943 size-full\" srcset=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png 904w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-291x300.png 291w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-768x791.png 768w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-585x602.png 585w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The rename command is a Perl-based utility in Linux used to rename single or multiple files quickly using pattern matching. It is especially useful when you need to modify filenames&hellip;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-411","post","type-post","status-publish","format-standard","hentry","category-miscellaneous"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/comments?post=411"}],"version-history":[{"count":5,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/411\/revisions"}],"predecessor-version":[{"id":16744,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/411\/revisions\/16744"}],"wp:attachment":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media?parent=411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/categories?post=411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/tags?post=411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}