Q: Remove the quoted form of POSIX path
Hi,
I use the quoted form of POSIX path in a AppleScript script to pass files in arguments to a shell script (an automator process (see man automator)).
When the process is finished, i'd like to pass the result to another action but the string is quoted like that :
"(
\"/Users/conmeubonailleuco/Temporaire/converted/01.One Way Ticket.mp3\",
\"/Users/conmeubonailleuco/Temporaire/converted/02.Knockers.mp3\"
)"
Instead of :
(
"/Users/conmeubonailleuco/Temporaire/converted/01.One Way Ticket.mp3",
"/Users/conmeubonailleuco/Temporaire/converted/02.Knockers.mp3"
)
What is the function to use to do that ?
Thx a lot.
Posted on Feb 1, 2016 2:14 PM
In AppleScript, you need to get paragraphs of output from shell script. Like this.
set theFiles to {"/path/to/file1.flac", "/path/to/file2.flac"}
set theArgs to ""
repeat with f in theFiles
set theArgs to theArgs & f & linefeed
end repeat
if theArgs ends with linefeed then set theArgs to theArgs's text 1 thru -2
-- theArgs = "/path/to/file1.flac" & linefeed & "/path/to/file2.flac"
set theWorkflow to "/Users/conmeubonailleuco/Library/Mobile Documents/com~apple~Automator/Documents/Encode Audio Files.workflow"
set theAutomatorScript to "automator -i " & theArgs's quoted form & " " & theWorkflow's quoted form
set thePostprocessor to " | sed -En 's/\"?,?$//; s/[\\]\"/\"/g; s/[\\]{2}/\\\\/g; s/[[:space:]]+\"?(.*)$/\\1/p'"
do shell script theAutomatorScript & thePostprocessor
return result's paragraphs
H
Posted on Feb 4, 2016 10:36 AM

