for i in res/drawable/thumb_???.png do basename=`echo $i | cut -d/ -f 3|cut -d. -f 1` echo $basename index=`echo $basename|cut -d_ -f2` echo $index svn mv res/drawable/$basename.png res/drawable/thumb_n_$index.png cat <<EOF > res/drawable/$basename.xml <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:drawable="@drawable/thumb_d_$index" /> <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/thumb_f_$index" /> <item android:state_pressed="true" android:drawable="@drawable/thumb_p_$index" /> <item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/thumb_s_$index" /> <item android:drawable="@drawable/thumb_n_$index" /> </selector> EOF done