How can I create a Finder alias in a bash script that reads arguments from the command-line?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I'd like to write a bash script that takes 2 inputs:
- path to actual file
- path of a Finder alias file (not a unix link) to be created that refers to 1.
The bash script should pass these inputs to an automation script that creates the alias.
I've seen How to use AppleScript in a bash script to create an alias for an app? but I have not been able to adapt it for my goal.
How can I do this?
terminal finder bash automation alias
add a comment |
I'd like to write a bash script that takes 2 inputs:
- path to actual file
- path of a Finder alias file (not a unix link) to be created that refers to 1.
The bash script should pass these inputs to an automation script that creates the alias.
I've seen How to use AppleScript in a bash script to create an alias for an app? but I have not been able to adapt it for my goal.
How can I do this?
terminal finder bash automation alias
add a comment |
I'd like to write a bash script that takes 2 inputs:
- path to actual file
- path of a Finder alias file (not a unix link) to be created that refers to 1.
The bash script should pass these inputs to an automation script that creates the alias.
I've seen How to use AppleScript in a bash script to create an alias for an app? but I have not been able to adapt it for my goal.
How can I do this?
terminal finder bash automation alias
I'd like to write a bash script that takes 2 inputs:
- path to actual file
- path of a Finder alias file (not a unix link) to be created that refers to 1.
The bash script should pass these inputs to an automation script that creates the alias.
I've seen How to use AppleScript in a bash script to create an alias for an app? but I have not been able to adapt it for my goal.
How can I do this?
terminal finder bash automation alias
terminal finder bash automation alias
asked Feb 2 at 9:00
foundartfoundart
1283
1283
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
With minimal error handling:
#!/bin/sh
[ -f "$1" ] || exit 1
[ "$2" ] || exit 1
alias=$(basename "$2")
/usr/bin/osascript <<EOF
tell application "Finder"
set myapp to POSIX file "$1" as alias
make new alias to myapp at Desktop
set name of result to "$alias"
end tell
EOF
mv ~/Desktop/"$alias" "$2"
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
With minimal error handling:
#!/bin/sh
[ -f "$1" ] || exit 1
[ "$2" ] || exit 1
alias=$(basename "$2")
/usr/bin/osascript <<EOF
tell application "Finder"
set myapp to POSIX file "$1" as alias
make new alias to myapp at Desktop
set name of result to "$alias"
end tell
EOF
mv ~/Desktop/"$alias" "$2"
add a comment |
With minimal error handling:
#!/bin/sh
[ -f "$1" ] || exit 1
[ "$2" ] || exit 1
alias=$(basename "$2")
/usr/bin/osascript <<EOF
tell application "Finder"
set myapp to POSIX file "$1" as alias
make new alias to myapp at Desktop
set name of result to "$alias"
end tell
EOF
mv ~/Desktop/"$alias" "$2"
add a comment |
With minimal error handling:
#!/bin/sh
[ -f "$1" ] || exit 1
[ "$2" ] || exit 1
alias=$(basename "$2")
/usr/bin/osascript <<EOF
tell application "Finder"
set myapp to POSIX file "$1" as alias
make new alias to myapp at Desktop
set name of result to "$alias"
end tell
EOF
mv ~/Desktop/"$alias" "$2"
With minimal error handling:
#!/bin/sh
[ -f "$1" ] || exit 1
[ "$2" ] || exit 1
alias=$(basename "$2")
/usr/bin/osascript <<EOF
tell application "Finder"
set myapp to POSIX file "$1" as alias
make new alias to myapp at Desktop
set name of result to "$alias"
end tell
EOF
mv ~/Desktop/"$alias" "$2"
answered Feb 2 at 10:00
nohillside♦nohillside
53.3k14112157
53.3k14112157
add a comment |
add a comment |