Created
March 27, 2013 19:16
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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