Sunday, November 25, 2007

Rename multiple files

Ever tried to rename multiple files???? Recently, one of my friends asked me, is there a way to change only the extensions for a set of files. After googling for some time, I got the following. Its really good.

In Linux,

rename gif jpg *.gif

This command replaces the occurance of gif (first parameter) in the file names with jpg ( second parameter) on all files (starting from third parameter)

In Windows,
ren *.gif *.jpg

It really works. I never thought windows has such useful stuff :D. But it works only on the extension. If u want to change the file name, instead of extension, it definitely fails.

Linux still rocks :)

4 comments:

Unknown said...

Tried renaming multiple files with out using extensions in Windows.. It worked...

Mani said...

I have the files as :
1aaa.txt, 2aaa.txt, 3aaa.txt

Executed the command :
ren *aaa* *bbb*

The output was :
1aaa.txtbbb 2aaa.txtbbb 3aaa.txtbbb

Unknown said...

U r right.. Mine was with extensions...

Rohith V said...

I wrote a script to do this with some sed and | just recently. And it worked too :) but ya, didn't really Google to get to rename