This tutorial will teach you how to change the default folder icon into your own custom folder icon using Terminal in Mac OSX.
After the completion of this tutorial, you will be able to navigate through the Mac OSX directory in Terminal and assign your own custom .png image as a folder icon.
To complete this tutorial, you will need access to a Mac OSX computer with at least 5 GB of available memory space. You must also have a basic understanding of how to use a Mac OSX computer and how to back up files.
Additionally, you will need to have Xcode command line tools installed. If you do not already have it installed, the section Installing Xcode Command Line helps guide you through the installation process.
Lastly, you will need to create a target folder and download a custom icon picked out in the form of a .png file placed inside. If you do not have an image file, you may choose from one of the default options provided in the section Downloading a Custom Icon.
Warning: If you have any important files on your desktop, make sure to back up these files in a separate location like on a flash drive or in OneDrive before proceeding any further. Using a UNIX Terminal can change your computer's file system and its data.
- Introduction to Terminal
- Getting Started
- Navigating a Directory
- Changing a Folder's Default Icon
- Wrap Up
This table lists all terminal commands used within this tutorial and states briefly what they do.
Terminal Commands | Description |
---|---|
xcode-select --install |
Installs Xcode command line tools |
xcode-select -v |
Prints the current version of installed Xcode command line tools |
sips -i icon.png |
Formats image .png file to icon .png file |
DeRez -only icns icon.png > tmpicns.rsrc |
Converts .png file to .icns file referenced through the tmpicns.rsrc file |
Rez -a tmpicns.rsrc -o Icon$'\r' |
Generates Icon? file from .icns reference file |
SetFile -a C . |
Sets Icon? file as the folder's custom icon |
SetFile -a V Icon$'\r' |
Hides the Icon? file inside the folder |
rm tmpicns.rsrc icon.png |
Removes unecessary leftover files |
rm Icon$'\r' |
Deletes the custom icon from the folder |
The downloads required for this tutorial are Xcode command line tools and at least one .png image file. Additionally, you will need to create a new folder on your desktop and place the image file inside.
If you know how to create a new folder, rename your folder as custom
and place your custom image into the folder. Then, skip to Navigating Directories.
Note: For the purposes of this tutorial, we will name and refer to the new folder as
custom
, but you can give the folder your own personalized name.
To create a new folder, you must do the following:
-
Navigate to your desktop home screen
-
Move your cursor to a preferred location and then press two fingers down on the track pad, or if you have an external mouse, right click on the folder to select it
-
Click on the option
New Folder
You should now see a blue default folder icon appear on your desktop.
To rename the folder, you must do the following:
-
Place your cursor over the folder and then select the new folder by either pressing two fingers down on the track pad or right click on the folder to select it
-
Click on the option
Rename
-
Type
custom
and then hitReturn↩︎
Your folder should now be named custom
.
Lastly, select the image file with your cursor and then drag it into the custom
folder.
Checkpoint: The custom image should now be inside the
custom
folder.
In order to change the default folder icon, we need to have a new icon file to change it to.
If you have a custom icon downloaded to your computer, move a copy of the image to the icon to your desktop and name it icon.png
.
If you do not have a custom .png file on hand, you can download an icon from here. Make sure to name it icon.png
and save it to your desktop.
Checkpoint: The custom image
icon.png
should now be saved on your desktop.
To open the Terminal application, you must do the following:
-
Press both the
Command ⌘
andSpace bar
keys on your keyboard at the same time to openSpotlight Search
-
Type the following text into the
Spotlight Search
prompt:Terminal
-
Press
Return↩︎
on your keyboard.
Checkpoint: A new Terminal window should be open and visible on your screen.
To install Xcode command line tools, you must do the following:
-
Open a new
Terminal
window -
Type the following text into the prompt:
xcode-select --install
-
When the pop up appears asking you if you would like to install the tools, click on the option
Install
. -
When the pop up appears stating the software was installed, click on the
Done
option.
If you would like to confirm your download, you can do the following:
-
Open a new
Terminal
window -
Type the following text into the prompt and then press
Return↩︎
:xcode-select -v
The resulting output prints your Xcode tools current installed version to the console.
Checkpoint: The Xcode command line tools should be installed on your computer.
When using Terminal
for any task, it is important to have a basic understanding of where our current location in the Mac OSX directory file system and how to move through the directory file system.
If you know how to navigate a directory file system in Terminal
, you may skip to Generating Icons.
To identify our current location in the directory tree, we can use pwd
.
Type the following text into the terminal prompt and then hit Return↩︎
:
pwd
The output printed to the console is shown below, where username
is the name of your computer's current user.
$ Users/username
Note: If the output printed to the console does not match the output format, type the following and then hit
Return↩︎
:cd ~; pwd
The figure below is an asbtract representation of our current location. Congrats, you are now in your computer's home directory!
Users/
└── username/
Checkpoint: The current location should be inside the
username
folder directory.
Now that we know where we are, we need to move to where we need to go.
Note: For the purpose of this tutorial, we will be working in your Desktop directory. If you would like to learn more about how to move through other directories, please see [insert link here].
To change our current directory to the Desktop, we can use cd
.
Type the following text into the terminal prompt and then hit Return↩︎
:
cd Desktop/custom/
If you would like to confirm you are in the Desktop directory, type the following text into the terminal prompt and then hit Return↩︎
:
pwd
Output:
$ /Users/username/Desktop/custom
The figure below is an abstraction of our current location. We are now in the custom
folder directory.
Users/
└── username/
└── Desktop/
└── custom/
├── icon.png
Checkpoint: The current location should be inside the
custom
folder directory.
Now that we are in the right location, we can now start converting icon.png
into a usable icon for the custom
folder.
To convert the image file, you must do the following:
-
Type the following text into the terminal prompt and then hit
Return↩︎
:sips -i icon.png
This command prepares the format of the png file for its transformation into an .icns file.
-
Type the following text into the terminal prompt and then hit
Return↩︎
:DeRez -only icns icon.png > tmpicns.rsrc
This command transforms the .png file into an .icns file and points to the newly converted file using the tmpicns.rsrc file.
-
Type the following text into the terminal prompt and then hit
Return↩︎
:Rez -a tmpicns.rsrc -o Icon$'\r'
This command generates the finalized icon file
Icon?
as a usable folder icon.
Checkpoint: The custom image file
Icon?
should be generated inside thecustom
folder.
With the correct icon file generated, we can now attach it to the folder itself so it can be displayed.
To attach the icon and set it visible, type the following text into the terminal prompt and then hit Return↩︎
:
SetFile -a C .
Checkpoint: The custom image file
Icon?
should now be visible as thecustom
folder's new icon.
To avoid accidental deletion of the Icon?
file, it is best to hide the file from normal view. In addition, removing the icon.png
and tmpicns.rsrc
files helps keep your newly customized folder tidy.
To hide the Icon?
file, type the following text into the terminal prompt and then hit Return↩︎
:
SetFile -a V Icon$'\r'
To remove unnecessary files, type the following text into the terminal prompt and then hit Return↩︎
:
rm tmpicns.rsrc icon.png
Checkpoint: The custom image file
Icon?
should now be invisible in thecustom
. The filestmpicns.rsrc
andicon.png
should also be gone from the folder.
If at any point you wish to remove the custom icon, you can do so by removing the hidden Icon?
file.
To remove the icon, type the following text into the terminal prompt and then hit Return↩︎
:
rm Icon$'\r'
With the file now removed, your folder icon should return to its default icon.
In this tutorial, you have learned how to:
- Open Terminal
- Change to the new folder's directory location
- Generate the icon file
- Attach the icon to the folder
- Hide the icon file
- Remove unecessary files
- Remove the custom icon from the folder