- Debian Admin - http://www.debianadmin.com -
Rename multiple files to another extension in Linux
Posted By Admin On 12th August 2007 @ 17:06 In General | 5 Comments
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
for old in *.php5; do cp $old `basename $old .php5`.php; done
Thats all there is to it. Let us say you need to rename index.php5 to index.php. The way above snippet works is that it loops through current directory and finds all the files with extension “.php5″ and processes ‘one by one. In our index.php5 file example, it finds index.php5 file, does a cp index.php5 `basename index.php5 .php5`.php <- basename returns “index” so you add .php to it and now you are left with index.php. Of course you can do mv command if you want to just move the file to new name.
Tag: Rename multiple files to another extension in LinuxYou may also be interested in...
Article printed from Debian Admin: http://www.debianadmin.com
URL to article: http://www.debianadmin.com/rename-multiple-files-to-another-extension-in-linux.html
Click here to print.