Would someone please explain to me this- I seem to have a malfunction with this for some reason.
choose folder with prompt "Choose folders for addition." with multiple selections allowed
set theList to result
tell application "Finder"
set newList to name of every item of theList
choose from list newList
end tell
This errors with “Can’t get name of {alias da:de:da:de:da}” but this
set newList to {}
choose folder with prompt "Choose folders for addition." with multiple selections allowed
set theList to result
tell application "Finder"
repeat with anItem in theList
set theName to name of anItem
set newList to newList & theName
end repeat
choose from list newList
end tell
works.
Of course what I want is to get a list of folders then choose them and add or delete folder references within the list and manipulate the files within. (who doesn’t?) I can usually get things to work, but every time I try something like this I strugle with the correct form to use from the start.
Simply put, you can’t use a list that way (whether or not you’re using the Finder).
I think you’re looking for something like this:
tell application "Finder"
activate
choose folder with prompt "Choose folders for addition:" with multiple selections allowed
repeat with thisFolder in result
get name of every item of thisFolder
choose from list (result)
end repeat
end tell
In your first example you are trying to get the name of every file in a list, but the list is not a file reference but a list of file references. You need to process each item in that list seperatly. The code below will do this, which is basically doing what Bruce posted, but builds single list to choose from. The problem that I see with this is that you would need additional code to find which folder in the selected folders that the list was built from, and since it is possible that there might exist a file with the same name in more than one folder then you might run into some problems.
set newList to {}
set theList to choose folder with prompt "Choose folders for addition." with multiple selections allowed
tell application "Finder"
repeat with AnItem in theList --repeat through the items in theList
set newList to newList & name of every file of AnItem --gets file name of every file in each folder
end repeat
choose from list newList
end tell
return newList