This repository was archived by the owner on Jan 8, 2023. It is now read-only.
File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ #
3
+ # Based on: http://hints.macworld.com/article.php?story=20021024064107356
4
+
5
+ if [ $# -eq 0 ]; then
6
+ echo " Usage: alias2ln alias1 alias2 alias3..."
7
+ echo " where alias1, alias2, etc are alias files."
8
+ echo " Each alias file will be converted into a symlink."
9
+ fi
10
+
11
+ while [ $# -gt 0 ]; do
12
+ if [ -f " $1 " -a ! -L " $1 " ]; then
13
+ item_name=` basename " $1 " `
14
+ item_parent=` dirname " $1 " `
15
+ item_parent=" ` cd \" ${item_parent} \" 2> /dev/null && pwd || echo \" ${item_parent} \" ` "
16
+ item_path=" ${item_parent} /${item_name} "
17
+ line_1=' tell application "Finder"'
18
+ line_2=' set theItem to (POSIX file "' ${item_path} ' ") as alias'
19
+ line_3=' if the kind of theItem is "alias" then'
20
+ line_4=' get the posix path of (original item of theItem as text)'
21
+ line_5=' end if'
22
+ line_6=' end tell'
23
+ linksource=` osascript -e " $line_1 " -e " $line_2 " -e " $line_3 " -e " $line_4 " -e " $line_5 " -e " $line_6 " `
24
+ if [ $? -eq 0 ]; then
25
+ if [ ! -z " $linksource " ]; then
26
+ rm " $item_path "
27
+ ln -s " ${linksource} " " ${item_path} "
28
+ echo " \" ${1} \" -> \" ${linksource} \" "
29
+ fi
30
+ fi
31
+ shift
32
+ fi
33
+ done
You can’t perform that action at this time.
0 commit comments