Skip to content

Instantly share code, notes, and snippets.

@motoishmz
Created March 10, 2014 06:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motoishmz/9460387 to your computer and use it in GitHub Desktop.
Save motoishmz/9460387 to your computer and use it in GitHub Desktop.
#!/bin/sh
cd `dirname $0`
dir_addons=$(cd ../addons; pwd) # {OFRoot}/addons
dir_aliases=$(cd $(dirname $0); pwd) # {OFRoot}/addons-alias
numOfxAddon=0
cd $dir_addons
for ofx in $(cd $dir_addons; ls | grep -e '^ofx[A-Z0-9]')
do
# $ofx is a directory name e.g. ofx3DModelLoader
if [ ! -d $ofx ]
then
continue # if it's not a directory
fi
theNameWithoutOfx=`echo $ofx | sed -e s/^ofx//` # 3DModelLoader
# alias source
path=$dir_addons/$ofx # {OFRoot}/addons/ofx3DModelLoader
script='(POSIX file "'$path'") as string' # e.g. Macintosh HD:Users:motoishmz:Desktop:OF008:addons:ofx3DModelLoader
srcHFSPath=`osascript -e "$script"`
# alias dest
path=$dir_aliases # {OFRoot}/addons-alias (a directory which will contains aliases)
script='(POSIX file "'$path'") as string'
dstHFSPath=`osascript -e "$script"` # e.g. Macintosh HD:Users:motoishmz:Desktop:OF008:addons-alias:
# creating an alias
echo "---"
echo "["$ofx"]"
script='tell application "Finder" to make alias file to alias "'$srcHFSPath'" at "'$dstHFSPath'"'
osascript -e "$script"
# renaming the alias to without-ofx-prefix style
beforeAbsPath=$dir_aliases/$ofx # {OFRoot}/addons-alias/3DModelLoader
afterAbsPath=$dir_aliases/$theNameWithoutOfx
`mv $beforeAbsPath $afterAbsPath`
echo "\nCreated '"$theNameWithoutOfx"' as the alias of "$ofx"\n"
numOfxAddon=`expr $numOfxAddon + 1`
done
echo "\n\n\n"
echo "・゜・*:.。..:* created "$numOfxAddon" aliases ・'。. .。.:*・゜・*"
echo "\n\n\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment