Skip to content

Instantly share code, notes, and snippets.

@ahknight
Created March 27, 2013 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahknight/5257172 to your computer and use it in GitHub Desktop.
Save ahknight/5257172 to your computer and use it in GitHub Desktop.
Strip Alias: Takes an existing post-Lion obese alias and creates a simple alias. Released into the public domain without restriction.
#!/bin/bash
# Strip Alias
# Released into the public domain without restriction.
#
# Takes an existing post-Lion obese alias and creates a simple alias.
SRC="$1"
DST="$2"
if [ -z "$SRC" -o -z "$DST" ]
then
echo "$0: missing arguments"
echo "usage: $0 source_file destination_file"
echo
exit
fi
if [ ! -r ${SRC} ]
then
echo "$0: abort: cannot read ${SRC} (does it exist? check permissions.)"
echo
exit
fi
if [ -f ${DST} ]
then
echo "$0: abort: destination must not already exist."
echo
exit
fi
# Get the source's vital data
CREATOR=`GetFileInfo -P -c ${SRC} | tr -d '"'` #"MACS"->MACS
TYPE=`GetFileInfo -P -t ${SRC} | tr -d '"'` #"fdrp"->fdrp
ATTRIBUTES=`GetFileInfo -P -a ${SRC}`
DeRez -s icns "$SRC" > /tmp/fork.r
# Build the file without the icon data
touch "$DST"
SetFile -P -c $CREATOR "$DST"
SetFile -P -t $TYPE "$DST"
SetFile -P -a $ATTRIBUTES "$DST"
Rez /tmp/fork.r -o "$DST"
# Cleanup
rm /tmp/fork.r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment