How to escape ")"?


I had to change a server’s password and created one that has a right parentheses in it = “)”.

As I changed things around to fit the new password I realized I had an AppleScript with this line

mount volume “afp://:<password_that_contains_)>@”

Well, it doesn’t work, as, it seems AS interprets the sentence as

mount volume "afp://:<password_that_contains_)

I just can’t find an escape character that works. I tried , and it doesn’t work.

I managed to make it acceptable as a variable value

set ThePassword to “password_that_contains_)”

but it seems that I can’t use a variable in a sentence like

mount volume “afp://:ThePassword>@”

Perhaps I could try to pass the password in a dialog box, but my knowledge of AS is rather limited.

Any help will be welcome.

Mario Jorge Passos

Hi Mario,

to avoid unexpected behaviour it’s not recommended to use filenames and passwords including special characters,
especially on file servers. Anyway, there is no way to escape a parenthesis (actually there is no need to) but you can put
almost everything into a variable in AppleScript

For example:

set user_name to "u_n"
set pass_word to "(p_w)"
set file_server to ""
set server_volume to "myVolume"
set s to "afp://" & user_name & ":" & pass_word & "@" & file_server & "/" & server_volume
tell application "Finder" to mount volume s -- works better with targetting the Finder
end try

Stefan, tks for your reply. I am trying to avoid changing the password as I will have to change it in several places. As the world is full of script kiddies trying to invade servers, I tried to make the password as hard to break as possbile.

Bad news: your solution doesn’t work. I removed the “tries” and got "The volume was not found. How do I output the value of “s” in the above example?



write just before the mount volume line:

display dialog s

Does the volume appear generally in Finder’s sidebar > Network?
On my machine the code works

I don’t manage to connect to the server. the “display dialog s” shows the proper value for s. But I get.

Finder got an error: Disk wasn’t found.

On the other hand if I try to connect manually the server is there as well the share. I believe that changing the password will be way out. :-/