Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I escape a slash in AppleScript? The documentation seems to suggest that

set target_string to "\\"

should return a single \, but in fact it returns \\\\. On the other hand,

set target_string to "\"

gives an error. I've tried this on Mac OS X v10.6 (Snow Leopard) and older versions of Mac OS X.

share|improve this question
    
Sorry, not sure what's going on for you, but set target_string to "\\" returns a single \ for me on Snow Leopard (10.6.4) –  ghoppe Jul 28 '10 at 15:48
    
And progress David? –  peelman Jul 28 '10 at 17:17
add comment

2 Answers 2

You should just be able to do:

set target_string to "\\"
share|improve this answer
    
Sorry, oddly enough SU read \\ as an escape in my original question. I've edited it. For some reason, your suggestion doesn't work on for applescript on my computers. –  David Zureick-Brown Jul 28 '10 at 15:40
2  
what happens when you do something like set target_string to "\\" then do a display dialog target_string. What you see in the "return" window in Script Editor isn't necessarily what other script objects see, especially true with Strings. like this: peelman.us/skitch/ase-slashes-20100728-114610.png –  peelman Jul 28 '10 at 15:45
add comment

Not sure why your sample code is not working on your system, but this should work too:

set target_string to ASCII character (92)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.