info home Info Homegeneral Generalwindows Windowsunix linux Linux/Unixdebian Debianmac os Mac OSapache Apachenginx Nginxiphone iPhone/iPod Touch

Tags

How to rename multiple files in Unix or Linux

Tags: unix, linux, shell, bash

To rename multiple files at the command prompt, you can use the rename command.

The manpages describes the usage as rename from to file

To rename all .csv files to .txt, this is what you do:

rename .csv .txt *.csv
Easy as pie!

To remove all spaces and tildes (~) from *.BAK files:

rename "s/[s+~]//g" *.BAK

To remove all .pl, .cgi and .sh extensions:

rename "s/\.pl$|\.cgi$|\.sh$//" *

Last Updated on 1 June 2010

If you liked this article, subscribe to our Feed, follow us on Twitter (@aruljohn) and/or join our Facebook Page.