Bash - rename multiple file extensions

I recently switched to Linux, and I want to change the file upload to have different extensions. For example, I want to change .doc / docx to .txt and images to .jpg and so on. Is there a csh script that will cover any extension or will I need to write a new one for each file type.

I still have it, but I'm not sure if this will really work. Any help is much appreciated!

#!/bin/bash
for f in *.$1
do
    [ -f "$f" ] && mv -v "$f" "${f%$1}$2"
done
+3
source share
3 answers

This will do the renaming; Keep in mind that renaming a Word document will not cause it to become text.

+2
source

No need to reinvent the wheel: http://linux.die.net/man/1/rename

rename .doc .txt *.doc
+5
source

:

+5

All Articles