AnsweredAssumed Answered

Need help with escaping some characters in calculated Applescript

Question asked by MikeWood on Nov 5, 2018
Latest reply on Nov 6, 2018 by MikeWood

I've got a bit of applescript that will remove the first line of a CSV file. I have a variable $path that contains the filepath of the CSV.


The native applescript works perfectly:



tell application "Finder"

  do shell script "sed -i \"\" '1 d' " & quoted form of POSIX path of "/Users/username/Desktop/TheFile.csv"

end tell


But I need to put the $path variable in instead of the absolute data, because the path could change.


When I try to calculate it, it keeps failing. I know that it has something to do with escaping the various characters inside but I'm admitting defeat and hoping someone smarter than I can help me.



Here's what I've been trying:

"tell application \"Finder\"¶

do shell script \"sed -i \\\"\\\" \'1 d\' \" \& quoted form of POSIX path of \""&$path&"\"¶

end tell"


Any ideas? I have tried only escaping the " and \ marks, but that also fails.