Can't escape "\|" in Applescript...

Hi am creating a dynamic list based on names of volumes currently mounted and need to be able to append “|” in-between each of the items, but there seems to be no way to escape it in Applescript. If I add 2 backslashes, it works but then I wind up with “\|” that doesn’t work. In fact, I can add as many even-numbered backslashes as I want, but none of them get me where I need to be.

Looking to create a string that looks like ‘item1|item2|item3|’ (then removing the final “|” with a text line.

Any ideas??

Thanks!!

There is a difference between the actual and presentation of a string. An escaped string is a string that is ready to be interpreted. So when you’re in AppleScript like looking in the log, writing a static string or see the result you see an uninterpreted string. That means when you see “\” the content is actually "". A good way to see the difference between those two is using a display dialog.

set volumes to AST list volumes without showing invisibles

set oldTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to "\\|"
set volumeString to volumes as string
set AppleScript's text item delimiters to oldTIDs

-- presentation of the string with single backslahes
-- you see the interpreted string here
display dialog volumeString

-- presentation of the same string in the result view with double backslahes
-- you see the uninterpreted string
return volumeString

p.s. the command AST list volumes is part of the AppleScript Toolbox.osax.