Sunday, August 16, 2009

Mass files renaming

Ever needed to change the extensions of the multiply files from one to the other? If you i.e. want to change all the files ended by .php3 to .php you could use the following command:

$ ls -d *.php3 | sed 's/\(.*\).php3$/mv "&" "\1.php"/' | sh

What we use here is sed replacing the part of the string (thanks to regular expression) with mv command and piping it to sh to which executes it. The detailed explanation of this process can be found here.

No comments:

Post a Comment