Hi, sorry to nag you people but I can’t find this one,
I have a list called resultList and it contains a few thousand items like “/This is a/Folder or File/Containing Spaces/But not Quoted/”
Either such a item can be a folder or a file. But the main problem is that it contains spaces and isn’t quoted.
They’re all POSIX paths.
And I can’t add items to the list as quoted form. (Explaining that would be posting a huge amount of lines of script here)
How could I convert all those paths to quoted paths ? Is this even possible? Maybe with text item delimiters?
Doesn’t matter, the spaced ones are enough but if it’s to hard to do only the spaced ones, then it wouldn’t matter because quoting all will give me the same result at the end. Whatever is easiest to code…
Quote each path individually (loop, quoted form of), then join them together with spaces (text item delimiters, . as unicode text) and use it in the command string:
set resultList to {"/foo/bar", "/baz/quxx"}
set quotedList to {}
repeat with p in resultList
set end of quotedList to quoted form of contents of p
end repeat
set text item delimiters to {space}
set cmd to "rm " & quotedList as Unicode text
do shell script cmd