Hands-on: Create an Executable for Your Android Workflow

Andrew Kelly
Groupon Design Union
4 min readAug 17, 2016

--

Upon exporting graphics from Sketch you’re left with many resolutions in a single folder. Organizing these resolutions into multiple folders for Android is a pain, so when I read “Better Android workflows with Sketch 3 and a bit of fairy dust” from Lindsay Mindler I was excited. She provides a great way to organize Sketch assets into Android folders using the command line. I wondered, maybe there is a way to store this fairy dust in a single command. The following is a way to achieve this using an executable file.

Open Text Edit app or your preferred text editor. Make sure the file is plain text. If you’re using Text Edit, in menu click ‘Format > Make Plain Text’. This ensures no additional invisible formatting is added to your file, breaking your code.

Copy this code and paste it into an empty Text Edit file. Name the file “androidFolders“. Uncheck the box that says “If no extension is provided, use .txt”. Save (⌘S) to your Desktop.

Click the ‘androidFolders’ file on your desktop and get info(⌘i). Click the lock in the lower right to unlock. Enter your password as needed.

The code will make 6 directories, one for each resolution. Then it will move each resolution with the suffix @1x, @2x, svg… into the right directory, and remove the uneeded suffix. Modify this to your liking, I’m sure it can be improved.

Open the Terminal app and navigate to the file we saved on our desktop. Change directories to root/Desktop with the command below.

cd ~/Desktop

Now that we’re in the Desktop directory we will change the mode of the androidFolders file to an executable. Type the command below.

chmod 700 androidFolders

Now we will use Terminal to move the file to your bin folder. This is where other executables on your computer live. Copy and paste the text below then type in your password when prompted. The password is needed since we used the ‘sudo’ command which means superuser do. You are indeed super.

If OSX Mavericks

sudo mv ~/Desktop/androidFolders /usr/bin/androidFolders

If OSX El Capitan

sudo mv ~/Desktop/androidFolders /usr/local/bin/androidFolders

Optional: To verify the file was moved, you can open Finder to your bin folder with this command.

If OSX Mavericks

open /usr/bin

If El Capitan

open /usr/local/bin

To use the command just navigate to where you’ve exported your assets. For this example, it’s our ‘assets’ folder on our desktop. Use the command below.

cd ~/Desktop/assets

Optional: Open this folder. So we can see the magic when we run the command.

open .

Then run the command.

androidFolders

As long as your files contain the @1x, @2x, @3x … suffixes, the command should work properly. You should see the directories appear and the files move into each directory.

You’re set! ✌️

Additional Tip: When you’re first getting comfortable with Terminal you’ll notice some directories and files are hidden. I found exposing the hidden files within Finder has helped me to better understand the system and navigate more easily. With time I’ve found the comfort in terminal. You can expose hidden files with this command.

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

Andrew Kelly is a product designer at Groupon in Seattle. Find him @ndrewkelly on Twitter.

Want to work with us? Browse our current job listings or learn more about us at Groupon Design Union.

P.S. — Thanks for reading! If you found value in this, I’d really appreciate it if you could recommend this post by clicking the ❤ button below so other people can see it.

--

--