I have files and directories starting with "cateory-icon-" in many sub directories. I am trying to rename them recursively to "category-icons-". Please note that I added missing "g" to the category and "s" at the end of icons.
I did look at tons of other questions dealing with renaming multiple files and directories but could not make any of them work for me!
A little bit explanation about the answer would be greatly appreciated.
EDITED: Here is an example of my directory structure:
test/cateory-icon-archery/cateory-icon-archery.png
cateory-icon-archery@2x.png
test/cateory-icon-automotive/cateory-icon-automotive.png
cateory-icon-automotive@2x.png
Best Answer
Since you need to do this recursively,
find
is the best tool to use. To alter the name, you can usesh
in the-exec
call. Here is an example:The
${1#cateory-icon-*}
expansion gets the filename aftercateory-icon
.