Skip to content

Instantly share code, notes, and snippets.

@rtrouton
Last active January 5, 2017 15:43
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtrouton/5f781c1cbeed1666121b to your computer and use it in GitHub Desktop.
Save rtrouton/5f781c1cbeed1666121b to your computer and use it in GitHub Desktop.
This script is designed to mine /Applications and /System/Library on OS X to copy all available icon files to one location.
#!/bin/bash
# Create a /tmp/icons.XXXX directory to
# store the copied images and icon files
TMPDIR=`/usr/bin/mktemp -d /tmp/icons.XXXX`
# The function below uses the image file
# format specified by the "filetype" variable
# to copy the relevant image and icon files
# from /Applications and /System/Library
GetIcons () {
mkdir "$TMPDIR"/"$filetype"
mkdir "$TMPDIR"/"$filetype"/Applications
mkdir "$TMPDIR"/"$filetype"/System
echo "Copying $filetype files to $TMPDIR/$filetype"
find /Applications 2>/dev/null -iname "*.$filetype" -type f -print0 | xargs -0 -I '{}' cp "{}" $TMPDIR/$filetype/Applications 2>/dev/null
find /System/Library 2>/dev/null -iname "*.$filetype" -type f -print0 | xargs -0 -I '{}' cp "{}" $TMPDIR/$filetype/System 2>/dev/null
}
filetype="icns"
GetIcons
filetype="png"
GetIcons
filetype="pdf"
GetIcons
echo "All finished! Copied images and icon files are available in $TMPDIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment