Artificial intelligent assistant

How can I rename all files with one extension to a different extension recursively Say I have a folder: / /a.bub /v.bub /dr.bub /catpictures /catpictures/or.bub /catpictures/on.bub How can I format a script to change each of these to `.aaa`. Here is what I've got, although it seems like a wrong approach: find -type f -name "*.bub" -print0 -exec mv

You could use `find` and `xargs`:


$ find some_folder -type f -name "*.bub" |
sed "s/\.bub$//" |
xargs -I% mv -iv %.bub %.aaa
`some_folder/a.bub' -> `some_folder/a.aaa'
`some_folder/v.bub' -> `some_folder/v.aaa'
`some_folder/dr.bub' -> `some_folder/dr.aaa'
`some_folder/catpictures/or.bub' -> `some_folder/catpictures/or.aaa'
`some_folder/catpictures/on.bub' -> `some_folder/catpictures/on.aaa'


... which you could generalise to a bash function:


$ extmv () {
find "${1}" -type f -name "*.${2}" |
sed "s/\.${2}$//" |
xargs -I% mv -iv "%.${2}" "%.${3}"
}


... which you'd use like this:


$ extmv some_folder/ bub aaa

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 4c5939ff00a02774f487b010c9e25a8f