mac emulation resources
mac emulation forums

26
Jul

How To Mass Extract Icons From A Mac

author alang

So you’ve been wandering in the downloads section for quite some time now, and you’ve come across a nice bulky set of Mac icons. You download it, and to your horror, when you’ve finally extracted it, you search and search, and you can’t find the icon you want! Where’s Word? Have you people ever heard of Photoshop?… etc, etc. The unfortunate truth is that an icon set will probably never capture every single household Mac app (What do you mean iDVD? I don’t have a Superdrive!). Surely an entire Windows community will not be fully content with just one or two big icon sets which contain too much of what you don’t need and only some of which you want.

But there’s a solution that’s not so painful. If you have access to a Mac with an older OS (think pre-Jaguar) or lots of goodies on it (some expensive software would be nice), then for the greater good of the online Mac emulation community you should start extracting icons!

This tutorial will tell you how to start mass-extracting and converting icon resources in very little time. It is assumed that you are sitting in front of a Mac running OS X and have already downloaded a batch icon conversion utility. I recommend Iconverter, an open source and small app found at http://www.students.niu.edu/~z110241/. You will need an icon converter because the standard icon format for OS X is ICNS (not PNG as suggested by the names of the Mac icon sets found at osx-e), which is sort of like Windows ICO. Everything else you need is inside the Mac. The actual extraction will be done using the Terminal (found at Applications/Utilities), but don’t sweat it, even if you have a deadly phobia of text-based interfaces, the bulk of the work is done for you. All you have to do is type EXACTLY what the tutorial says (mind you, it’s pretty fool-proof, but a really bad typo can make things turn very ugly, so it’s in your best interest to be cautious if you haven’t used the Terminal before).

Before we start, make sure that you are running the bash shell on your Terminal. If the Mac has Jaguar or above, bash is pre-installed on the system. For older Macs, follow the directions on http://www.savagetranscendental.com/tip3_old.html. To verify that you are running bash, type “bash” in the Terminal and hit return.

If you have previously downloaded the readme file for the 1400 Tiger PNGs icon set found in osx-e downloads section, you will find a note which has the following lines:

find / -name "*.icns" > ~/Desktop/icnsfile
echo "items to copy found"
IFS="
"
for i in $(cat ~/Desktop/icnsfile)
do
echo "copying $i"
cp $i ~/Desktop/ICNS/${i//\//&}
done

This is the basic shell program source code which we will use to extract ICNS resources. But don’t paste it into the Terminal and hit return, a few tweaks have to be done to it in order for it to be safe to run on your system’s configuration. I used the previous script to run on my computer because I had already done everything needed in order for it to run correctly. For the potential audience of millions of Mac users, I have to change it around a bit yet for you:

#!/bin/bash
if [ ! -d ~/Desktop/ICNS ]
then mkdir ~/Desktop/ICNS
fi
find / -name “*.icns” > ~/Desktop/icnsfile
echo “items to copy found”
IFS=”

for i in $(cat ~/Desktop/icnsfile)
do
echo “copying $i”
cp $i ~/Desktop/ICNS/${i//\//&}
done

This version is not that different from the previous one, but it is my future goal to make these scripts more user-friendly, even a complete Terminal application tutorial.
In future versions I will also give a step-by-step breakdown of the script if users request it so.
The above larger script is a safe alternative to my smaller version which I ran to copy the 1400 Tiger icons. Now we are ready to save and run it.

Open up TextEdit and paste that script into a new text file. Go to Format > Make Plain Text. Now save it as something like “icnsscript” in your home directory. When you save it, uncheck the box that says “If no extension is provided, use .txt”. We are almost ready to run this script.

Check to make sure that on your Desktop you have no files named “icnsfile” and no folder called ICNS. If so, please rename them.

Now run the Terminal again. Type “ls” and hit return. Make sure that one of the words returned is the name of the script file which you saved. Then type and hit return:

chmod +x yourscriptfile

where “yourscriptfile” is the name of the script file which you saved. That will allow the script to be executed. To actually execute the script, type:

sudo ./yourscriptfile

and hit return. Again “yourscriptfile” is the name of the file you saved. The “sudo” part will allow you to run the script with the most powerful privileges, so that it is sure to get every ICNS file. Because you typed “sudo” it will ask you for your user password, so type it in and the script will then start running. Don’t worry if you don’t see “****” characters where you are typing your password, the Terminal does not display them.

Check your Desktop for two new items: a file called icnsfile and a folder ICNS. The Terminal will remain unresponsive for a while.
After about five minutes lines of text should begin to scroll down, which say “copying” and then some file name.

When the script is done you will be returned to a normal prompt and no more lines will scroll. Wipe the sweat off your face, we are done with the command line part.

Open up the folder ICNS and determine that there are many files in there with the extension *.icns. These are all your system’s ICNS resources copied into that one folder! If you want to convert them into PNGs or other formats read on.

Create a new folder where you would like the converted files to be put in. Then open up Iconverter and do the following:
-under “source file”, click the “Choose” button and select the folder ICNS on your desktop
-check the box that says “Batch process contents if folder.”
-check “Use file content”
-under Destination Files, click “Choose” and select your folder which you created to store the converts.
-uncheck “Create thumbnail” and “Draw background”
-next to “File Format” select the type of file you would like them converted into
-in the drawer that popped up after you select ICNS, click the Extract button and wait just like you did for the Terminal. they will now be converted.

Enjoy your converted icons. Archive them and put the interesting ones up for download at osx-e.com!


Comments »

No comments yet.

Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.