Skip to content

Instantly share code, notes, and snippets.

@mhemmings
Created May 3, 2016 13:17
Show Gist options
  • Save mhemmings/bb8d02ce7487f990ceb45b5d0e7288fa to your computer and use it in GitHub Desktop.
Save mhemmings/bb8d02ce7487f990ceb45b5d0e7288fa to your computer and use it in GitHub Desktop.
cp-drawables.sh

Copy Android drawable assets from one directory to another using the standard drawables-hdpi, drawables-xhdpi etc

It can be a pain to copy new assets into your Android project when they are provided in the correct dpi directory structure. Inside the source res directory, you should have child directorys of drawables-hdpi, drawables-xhdpi etc which each contain the asset needed to copy. The destination directory should also be the res directory containing each drawables directory.

Example: ./cp-drawables.sh img_to_copy.png /path/to/res/dir

Will execute (and print out):

cp drawable-mdpi/img_to_copy.png /path/to/res/dir/drawable-mdpi/img_to_copy.png
cp drawable-hdpi/img_to_copy.png /path/to/res/dir/drawable-hdpi/img_to_copy.png
cp drawable-xhdpi/img_to_copy.png /path/to/res/dir/drawable-xhdpi/img_to_copy.png
cp drawable-xxhdpi/img_to_copy.png /path/to/res/dir/drawable-xxhdpi/img_to_copy.png
cp drawable-xxxhdpi/img_to_copy.png /path/to/res/dir/drawable-xxxhdpi/img_to_copy.png
#!/bin/bash
for file in drawable-*dpi/$1
do
CMD="cp ${file} $2/${file}"
echo $CMD
$($CMD)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment