Recursively rename files (change extension) in Linux

Figured it out

find . -name "*.andnav" -exec rename -v 's/\.andnav$/\.tile/i' {} \;
./0/0.png.andnav renamed as ./0/0.png.tile
./0/1.png.andnav renamed as ./0/1.png.tile
./1/0.png.andnav renamed as ./1/0.png.tile
./1/1.png.andnav renamed as ./1/1.png.tile

of course remove the -v when actually doing it, or it will waste time displaying all the files


With zsh:

autoload zmv
zmv -n '(**/)(*).andnav' '$1$2.tile'

Remove the -n to actually perform the renaming.


Something like:

find . -name '*.andnav' -exec sh -c 'mv "$0" "${0%.andnav}.tile"' {} \;

Explanation

The above starts walking the directory tree starting at the current working directory (.). Every time a file name matches the pattern *.andnav (e.g., foo.andnav) the following command is executed:

sh -c 'mv "$0" "${0%.andnav}.tile"' foo.andnav

Where $0 is foo.andnav and ${0%.andnav}.tile replaces the .andnav suffix with .tile so basically:

mv foo.andnav foo.tile