Skip to content

Instantly share code, notes, and snippets.

@rasagy
Last active May 19, 2016 11:20
Show Gist options
  • Select an option

  • Save rasagy/6d30a165b6bb6336259c to your computer and use it in GitHub Desktop.

Select an option

Save rasagy/6d30a165b6bb6336259c to your computer and use it in GitHub Desktop.
Rearrange Android Assets exported from Sketch
# Use Sketch Export to export each asset in one folder with suffix as: -mdpi (1x), -hdpi (1.5x), -xhdpi (2x), -xxhdpi (3x), -xxxhdpi (4x)
# Then, open terminal in that folder and run this command.
# Find all exported assets in a separate ../res/ folder.
# Feel free to remove ../ in case you want the res folder _inside_ your assets folder.
mkdir ../res/drawable-xxhdpi; mkdir ../res/drawable-xhdpi; ../res/mkdir drawable-hdpi; ../res/mkdir drawable-mdpi
done
for file in $(find . -type f -iname '*-xxxhdpi*'); do
mv "$file" "../res/drawable-xxxhdpi/${file/-xxxhdpi/}"
done
for file in $(find . -type f -iname '*-xxhdpi*'); do
mv "$file" "../res/drawable-xxhdpi/${file/-xxhdpi/}"
done
for file in $(find . -type f -iname '*-xhdpi*'); do
mv "$file" "../res/drawable-xhdpi/${file/-xhdpi/}"
done
for file in $(find . -type f -iname '*-hdpi*'); do
mv "$file" "../res/drawable-hdpi/${file/-hdpi/}"
done
for file in $(find . -type f -iname '*-mdpi*'); do
mv "$file" "../res/drawable-mdpi/${file/-mdpi/}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment