Quote paths in list.

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?

Thanks

Hi,

is it necessary to quote all paths in the list?
You need the quotation only when you use the path as an argument in a shell script call

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…

Ok I figured something out, I used

set AppleScript's text item delimiters to return
set theList to every text item in thingy
set end of resultList to result
resultList as text

the result :
“/path/of/files/or/folders
/with/no/quotes/
/but/as/posix/path”

How do I use all these items in a shell script ?
for example, deleteting all those files?

Or if the above isn’t possible, deleting those files with the Finder ?

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

Thanks, everyone.