I have a script that plays a random sound from a known folder. It uses two external applications to actually play the sound depending on its sound type (mp3 or sfil). When I save it as an application, when it runs, it asks “Where is the external application?”. I tried setting the folder of the application in the script but apparently that is not working. I am an Applescript noob, so any help would be appreciated. The script used to work just fine, but after an upgrade somewhere along the line it stopped. Any ideas???
P.S. If you see anything that is done not very efficiently, an improvement suggestion would be helpful as well.
tell application "Finder"
if folder "Startup Sounds" of folder "DocuMents" of folder "mkaz" of folder "Users" of startup disk exists then
set ssf to folder "Startup Sounds" of folder "DocuMents" of folder "mkaz" of folder "Users" of startup disk
set n2 to count of folders of ssf
set x2 to 0
repeat while x2 < 1
set x2 to random number n2
end repeat
set n to count of files of folder x2 of ssf
set x to 0
repeat while x < 1
set x to random number n
end repeat
set sfile to file x of folder x2 of ssf as text
if ".mp3" is in sfile then
-- "use QuickStartupSound"
set qfold to folder "QuickStartupSound" of folder "Applications" of startup disk
try
delete file "defaultsound" of qfold
end try
make alias at qfold with properties {name:"defaultsound"} to sfile
launch application "Quick Startup Sound" of qfold
else
-- use "ClassicStartupSound"
set qfold to folder "ClassicStartupSound" of folder "Applications" of startup disk
try
delete file "defaultsound" of qfold
end try
make alias at qfold with properties {name:"defaultsound"} to sfile
launch application "Classic Startup Sound" of qfold
end if
end if
end tell