I’m trying to loop through a string to create a variable list. I’ve done something similar in a different portion of the script, but I’m having trouble with the new one I want to add. The weird thing is that it works fine when I run it in ScriptEditor, but it fails as a folder action.
set prefDomain to "com.daviesprinting.hotfolderrouter"
set serverChoices to {"Donatello", "Apogee1", "Creo", "Wyeth"}
set volumeChoices to {}
set theServer to (choose from list serverChoices with prompt "Select Destination Server:" default items item 1 of serverChoices) as string
set availableVolumes to (do shell script "defaults read " & prefDomain & " \"" & theServer & "\" | cut -s -f2 -d\":\" | sort -u")
repeat with i in words of availableVolumes
set end of volumeChoices to i
end repeat
display dialog volumeChoices
The “do shell script” in the second line returns a comma delimited list of names. When I run this in ScriptEditor, the display dialog at the end errors because it cannot change the list “volumeChoices” into a string – which is what I would expect it to do. If I run the same thing as a folder action it crashes somewhere. Adding various display dialogs for debugging seems to show that volumeChoices is not being treated as a list in the repeat.
Any ideas? Could it be that all the quote marks in the do shell script are being handled differently between the ScriptEditor and Folder Actions?
GRRRR!
T.