Rename File extensions

bash script to rename file extensions


Author: Anonymous
Added: Wednesday, 21 May, 2014
Category: Terminal

Code

# change .htm files to .html
for file in *.htm ; do mv $file `echo $file | sed 's/\(.*\.\)htm/\1html/'` ; done

# change .html files to .htm
for file in *.html ; do mv $file `echo $file | sed 's/\(.*\.\)html/\1htm/'` ; done

#change .html files to .shtml
for file in *.html ; do mv $file `echo $file | sed 's/\(.*\.\)html/\1shtml/'` ; done

#change .html files to php
for file in *.html ; do mv $file `echo $file | sed 's/\(.*\.\)html/\1php/'` ; done

# change .JPG files to .jpg
for file in *.JPG ; do mv $file `echo $file | sed 's/\(.*\.\)JPG /\1jpg/'` ; done

Comments