AppleScript: list files in folder

Discussion in 'Mac Programming' started by the Otter, Apr 5, 2011.

  1. the Otter macrumors member

    Jan 10, 2001
    Lafayette, IN
    Okay, folks. This is an incredibly weird one. I know this has worked before. I stripped the code down to its barest form, so here it is, in its entirety:

    tell application "Finder"
    	set theFolder to choose folder
    	set fileList to every file in theFolder
    end tell
    When I run it—regardless of the folder I choose—I get the following message:

    AppleScript Error
    Finder got an error: Can’t get alias "[path to folder]".

    Anyone got any thoughts? I’m banging my head against this one.
  2. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    What OS version?

    Where are you running it from? AppleScript Editor? Something else?

    Exactly which folders have you tried it on? Be specific.

    What user account are you logged in as?

    Break It Down.

    If you take out the second line, what is the resulting theFolder value? What is its type? Is it a string, an alias, a fnord, something else?

    If you change the variable name from theFolder to myFolder or eineKleineFnordMusik, what happens?

Share This Page