How to rename android assets recursively and replace dash for underscore

Viewed 1352

I have some assets that my designer have created, he branched them correctly making all dpi's match their directories so I was happy because I didn't had to copy those files to each subfolder but when I checked out their names they had dashes in the filenames, which made android compiler to fail.

So how I can make a bash script to rename all files below drawable-*, to the same file name but replacing dashes with underscores?

Example:

Convert this :

drawable-hdpi/
    my-icon.png
    my-icon-2.png
drawable-xhdpi/
    my-icon.png
    my-icon-2.png
drawable-xxhdpi/
    my-icon.png
    my-icon-2.png

To this:

drawable-hdpi/
    my_icon.png
    my_icon_2.png
drawable-xhdpi/
    my_icon.png
    my_icon_2.png
drawable-xxhdpi/
    my_icon.png
    my_icon_2.png
3 Answers
Related