0

I have a basic applescript to request a user's input, then pass the variable into a path for mounting a volume:

display dialog "What is the first letter of your last name?" default answer ""
set LastNameInitial to text returned of result

mount volume "smb://ServerName/files/myfiles/LastNameInitial"

However, when this is executed, it fails to mount the volume as it does not exist because it is trying to mount the literal path above and not using the variable. What am I doing wrong?

2
  • 1
    untested… mount volume "smb://ServerName/files/myfiles/" & LastNameInitial
    – Tetsujin
    Commented Jun 15, 2015 at 19:50
  • Moving this to an answer just to keep things tidy...
    – Tetsujin
    Commented Jul 11, 2015 at 10:19

1 Answer 1

1

You need to just add the variable to the end of your predetermined path string, like this…

set LastNameInitial to ""
repeat while LastNameInitial is ""
    display dialog "What is the first letter of your last name?" default answer ""
    set LastNameInitial to text returned of result
    if LastNameInitial is not "" then
        mount volume "smb://ServerName/files/myfiles/" & LastNameInitial
    end if  
end repeat

I added a safety net just in case they don't enter an initial, which will keep springing the same dialog until they do, or cancel

You must log in to answer this question.

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