0

I'm trying to write an AppleScript to make a temporary alias on the desktop from a folder that resides in the Bundle's Contents:Resources folder and then execute a terminal command that has an argument from a file that also resides in the Bundle's Contents:Resources folder and then remove the temporary alias from the desktop upon finish or exit.

How do I fix the following code to accomplish this?

set myRes to (path to me as text) & "Contents:Resources:"

tell application "Finder"
     make new alias to folder myRes & "Pass-Through Drive" at desktop
end tell

tell application "Terminal"
     activate
     do script myRes & "BasilliskII --config basilisk_ii_prefs"
end tell

tell application "Finder"
     delete file "Pass-Through Drive" of desktop
end tell

This is the error I get:

error "Can’t make «class cfol» \"Resources\" of «class cfol» \"Contents\" of «class appf» 
  \"Mac OS 8.1.app\" of «class cfol» \"Desktop\" of «class cfol» \"ryan\" of «class cfol»
  \"Users\" of «class sdsk» of application \"Finder\" into type list, record or text."
  number -1700 from «class cfol» "Resources" of «class cfol» "Contents" of «class appf» 
  "Mac OS 8.1.app" of «class cfol» "Desktop" of «class cfol» "ryan" of «class cfol» "Users"
  of «class sdsk» to list, record or text

I think I've corrected it down to...

set myRes to (path to me as text) & "Contents:Resources:"

tell application "Finder"
     make new alias to folder (myRes & "Pass-Through Drive") at desktop
end tell

tell application "Terminal"
     activate
     do script myRes & "BasilliskII --config " & myRes & "basilisk_ii_prefs"
end tell

tell application "Finder"
    delete file "Pass-Through Drive" of desktop
end tell

but still having trouble with the middle lines and the proper syntax of what I'm trying to accomplish.

1

You don't need to tell Terminal to run the script (unless you just want to lay eyes on it). But also you'll want to use a posix path escaped to prevent errors.

You could do it like ...

set myRes to alias (path to me as text) & "Contents:Resources:"

tell application "Finder"
     make new alias to folder (myRes & "Pass-Through Drive") at desktop
end tell

set posixRes to (POSIX path of myRes)

do shell script quoted form of posixRes & "BasilliskII --config " & quoted form of posixRes & "basilisk_ii_prefs"

tell application "Finder"
    delete file "Pass-Through Drive" of desktop
end tell
  • I get an error with that: Finder got an error: Can’t make {alias "Macintosh HD:Users:ryan:Desktop:Mac OS 8.1.app:", "Contents:Resources:", "Pass-Through Drive"} into type integer. – CyberManifest Nov 14 '14 at 17:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .