on substitute()
try
set rubyScript to "linktunes.rb"
set resourcesFolder to (container of (path to me))
set scriptPath to quoted form of POSIX path of (resourcesFolder & rubyScript)
if (do shell script "if [[ -f " & scriptPath & " ]]; then echo exists; fi") ≠ "" then
return do shell script scriptPath
else
return "Error: " & scriptPath & " does not exist"
end if
on error errorString
return "Error: " & errorString
end try
end substitute
Everything on the web indicates that `(container of (path to me))` should provide me with an alias to the folder containing the script - instead, I get this error:
"Error: Can’t get container of alias \"Geoffrey's RAID:private:var:folders:P2:P2S5eg-AGTiyqxkapijleU+++TI:-Tmp-:untitled_1odf.tmp\"."
(That's just an example, I get that error no matter where I save the file or even if I try running it as an unsaved file in the Script Editor).
How can I get a string containing the path of a file adjacent to the script being run (specifically, to be passed to `do shell script`)?