removing file extensions from multiple files.

From Carlo Perassi (http://perassi.org/), a nice example of how to use awk and the parentheses in the bash shell to remove file extensions from multiple files.


# substitute jpg with the extension you need (twice in the line)
for i in $(ls *jpg | awk -F "." '{print $1}'); do mv $i.jpg $i; done

in case you don’t have rename installed (which I didn’t on my work machine here, where I have to use Windoze and Cygwin because I’m running SIENA). Otherwise

rename 's/\.jpg$//' *.jpg

Leave a Reply

You must be logged in to post a comment.