find . -name "*.flv.mp4" | while read file; do echo "$file"; mv "$file" "${file%.flv.mp4}.mp4" #mv "$file" "$(expr "$file" : '\(.*\)\.flv.mp4').mp4" done;
Notes:
rename
rename does not work: “$rename .html .txt *.html” results in… syntax error at (eval 1) line 1, near “.”
basename
basename does not work – only renames the filename and strip path!
echo "`basename $file .html`.txt"
Using for loop – 3 levels
for fname in * */** */*/**; do if [ -f "$fname" ]; then echo "$fname"; fi; done;
Using for loop – 1 level
for fname in **/*; do if [ -f "$fname" ]; then echo "$fname"; fi; done;
References
1. http://www.unix.com/shell-programming-scripting/60471-recursicely-search-rename-file-extension.html
2. http://stackoverflow.com/questions/1086502/rename-multiple-files-in-unix
3. http://www.itcs.umich.edu/itcsdocs/s4148/#name
4. http://unix.stackexchange.com/questions/18455/recursive-rename-files-and-directories
5. http://unix.stackexchange.com/questions/13147/rename-all-the-files-within-a-folder-with-prefix-unix
man rename