Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am currently using this UNIX shell command in my script file:

do shell script "open ~/Dropbox/Media/VisionBoard/*"

Is there another way to do it and if so would it be any better or different? I'm still new to programming, so please be gentle.

share|improve this question
up vote 4 down vote accepted
tell application "Finder"
    set myFolder to ((home as text) & "Dropbox:Media:VisionBoard") as alias
    set myFiles to (every item of myFolder) as alias list
    open myFiles
end tell

Instead of "every item" you can also say "every file" or "every folder".

share|improve this answer
What's the significance of "as alias," and is that why we can't say open every item of ((home as text) & "Dropbox:Media:VisionBoard")? – NReilingh Aug 12 '10 at 18:42
I am no AppleScript guru, just a student. There may be many ways to do it. From Apple's AppleScript Language Guide: “An alias object is a dynamic reference to an existing file system object. [...] The following is the recommended usage for these types: * Use an alias object to refer to existing file system objects. * Use a file object to refer to a file that does not yet exist.”… – ischeriad Aug 12 '10 at 19:18
@NReilingh By default, Applescript treats the bracketed term as a string. The every keyword specifies every object in a container. Strings contain characters. If you try and open every item of a string, AppleScript will throw an error because it can't convert the characters into type item. Items in the Finder are files, folders, etc. Therefore you coerce the file path string to an alias, which is a reference to an existing file, folder, or volume in the file system. The Finder can then treat that alias as a container of file system items. – ghoppe Aug 12 '10 at 19:52
Thanks for the discussion. It gave me some great insights as to how AppleScript works. The information is probably of no tangible use, but can anyone confirm my suspicion that running pure AppleScript is more efficient than using it to perform a shell script? – Orion751 Aug 13 '10 at 18:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .