Using dropdown lists and making the choice text a variable


Does anybody know how to use dropdown lists (or just a list) and set the choice to a text variable? I don’t know :oops: (well duh or i wouldn’t be asking)


There is no popup menus in plain AppleScript, but you can use ‘choose from list’.

set the_list to {1, 2, 3}
choose from list the_list
set user_choice to result
if user_choice is false then return
display dialog user_choice

Don’t know what you mean by:

set the choice to a text variable


it works thanks

you covered the text variable thing

This bit of code is just what I was looking for but I’ve run into a snag with it. I want to use the results from the list as part of a directory name. When I tried it, I get an error that Finder can’t make it “into type Unicode text”.

Does anyone know how to fix that?

Thanks in advance!!!

Model: Mac Pro
Browser: Firefox
Operating System: Mac OS X (10.5)

post your code you are using.

Here you go…

The whole thing is a merging of the code from this thread and the one from here:

It work perfectly until I tried to make the result from the list part of the folder name.

(And my thanks to both the contributors!)

However the result from Script Editor is:

Finder got an error: Can’t make {“Misc”,“-”,“Test”,“-”,“20080220”} into type Unicode text.

set typeList to {"Band", "Engagement", "Headshot", "Event", "Misc", "Performance", "Personal", "Photoshoot", "Wedding", "OTHER"}
choose from list typeList
set user_choice to result
set typeName to text of user_choice
set shootName to text returned of (display dialog "Photo project NAME?" default answer "")
set projectDate to do shell script "date +%Y%m%d"
set projectName to typeName & "-" & shootName & "-" & projectDate
set new_sub_list to {{"1-Original Files", {"Selected", "Rejected", "Miscellaneous"}}, {"2-Workroom"}, {"3-Output", {"Print Ready", "Web-Proof Only"}}, {"4-Other"}}
tell application "Finder"
set baseFolder to make new folder at folder "In Progress" of folder "Photography" of disk "Workroom" with properties {name:projectName}
repeat with i from 1 to count new_sub_list
set {tier2, t2Subs} to {item 1, item 2's items} of item i of new_sub_list
set tier2Folder to make new folder at baseFolder with properties {name:tier2}
repeat with tier3 in t2Subs
make new folder at tier2Folder with properties {name:tier3}
end repeat
on error
make new folder at baseFolder with properties {name:(item 1 of item i of new_sub_list)}
end try
end repeat

Add “as string”

set projectName to typeName & "-" & shootName & "-" & projectDate as string



PERFECT!!! :smiley: :smiley:

And thank you very much! Your help is greatly appreciated.

You are very welcome. :slight_smile: