I’m trying to write a script that requires replacing spaces in file names with "\ ". This is what I have so far.
set myPath to (path to me) as text
set LibPath to path to library folder as text
searchReplace(LibPath, ":", "/")
searchReplace(myPath, " ", "\ ")
to searchReplace(thisText, searchTerm, replacement)
set AppleScript's text item delimiters to searchTerm
set thisText to thisText's text items
set AppleScript's text item delimiters to replacement
set thisText to "" & thisText
set AppleScript's text item delimiters to {""}
return thisText
end searchReplace
Unfortunately, the moment I use a backslash in the code, even in quotations, I get and error. If anyone’s wondering, I’m trying to turn an alias into a path that can be used in terminal.
Thanks in advance!