I’m having having trouble with setting a dialog to a certain result. What I want to do is to list the folders, aliases and items whose name extension is in the extension list of the chosen directory.
Also, if possible, I want the items of the resulting list in the same order as they appear in the directory (or alphabetically).
The line looks like this and returns an error:
set itemList to (every item of currFolder whose name extension is in the extensionList) & (every folder of currFolder) & (every alias of currFolder)
Script doesn’t accept the “alias” part
If I remove that part, I get a result, but only if there are files with the requested name extension
The result is sorted files & folders (I know I can use a sorting routine, but that makes the script too slow - at least the way I’ve experimented with it - so if it’s not possible to do this in an easy way, I can live with this)
thanks! That did exactly what I wanted it to do, even though I don’t need different variables for the different kind of items. But by separating the items from each other you helped me understand why my script didn’t work: the error occured when there were no files with the requested name extension. So I added a line that checks this first, and changed your script to this:
set extensionList to {“jpg”, “tif”, “pdf”, “rtf”}
tell application “Finder”
activate
set currFolder to (path to desktop folder) as alias
count (every item of currFolder whose name extension is in extensionList)
if result is 0 then
set itemList to (name of every folder of currFolder) & (name of every alias file of currFolder)
else
set itemList to (name of every item of currFolder whose name extension is in extensionList) & (name of every folder of currFolder) & (name of every alias file of currFolder)
end if
set the_item to (choose from list itemList) as string
if the_item = “false” then return
set the_item to ((currFolder as string) & the_item) as alias
return the_item
end tell
I don’t know if that’s the neatest way to do it (?), but as long as it works I’m happy.
Thanks again for your help!
Snarb