Renaming multiple files with same extension [1/1]

Type: Code
Level: Beginner  
Date: 2007-Feb-10
Visited: 620 times
Rating:
Author: Tony Potter

This tutorial will show you how, with one raw command to rename multiple files using bash scripting.
It is written for Linux/Unix bash shell and will be useful when you want to rename files with same extension.

Here is the syntax of the string:

for i in * ; do mv "$i" `basename "$i" .ext1`.ext2 ; done
This line all will change all files with extension 'ext1' to 'ext2' .

The next example will convert all '.JPG' files to '.jpg' .It is really useful when you have moved files from Windows OS where the case of the extensions does not matter, but under Unix/Linux will be a problem if you are managing many files, like in galleries, photo albums etc.

for i in * ; do mv "$i" `basename "$i" .JPG`.jpg ; done
Rate this tutorial:                    
- Renaming multiple files with same extension [1/1] -

Need a specific tutorial? Do not hesitate and submit a request!
Related Tags: linux mv multiple files commands  rename multiple files linux  rename multiple files linux  linux rename multiple files  How to move multiple files using mv command in unix  rename multiple files command example in Linux  multiple constructors C++  tutorials on uploading files to FTP using c++  unix how to rename files  making 3d flash files