Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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