getting the names of items in a folder

hello,
I was trying to write a script that would return the name of every item in a folder. I can get it to work only for the startup disk…can someone look at this and tell me why it gives e the mesage "can’t get folder “Documents” of folder “Users” of the starup disk.

tell application "Finder" to get the name of every item of the folder "applescripts" of the folder "Documents" of the folder "Users" of the startup disk

thanks
babs

Use the list folder command.

list folder (path to desktop)

Hi,

the user name is missing (folder “Documents” of folder “myUser” of folder “Users” of startup disk)
I recommend to use the “shortcut” to the documents folder of the current user


tell application "Finder" to get name of every item of folder "applescripts" of (path to documents folder)

thanks guys!! Makes sense to reference that way :smiley:

Try this.

with help from the last post.

set bpressfolder to path to documents folder from user domain as string
set scrptsfolder to bpfolder & "applescripts" & ":" as alias
list folder scrptsfolder

Val

hi Val,

sorry, I don’t know how to create variables yet…I’m only on page 154 of this applescript book, but no variables yet ;-(
thanks anyway…Hope to get there soom :slight_smile:

babs

154 pages without variables is pretty weird.
Actually the first line of AppleScript you’re going to learn in any book is

set x to 1

:wink:

Hi Stefen,

yeah…I got about 100 more pages to go before I hit variables… LOL
I’m working through Sal Soghoin and Bill Cheeseman’s Applescript 1-2-3 Book. It’s very good, all 800 plus pages of it…little by little I am getting there…thanks to people like you :smiley:

babs

Here is something. If a command returns something, you can apply that value to a variable.

The following should return {button returned:“Good.”} :

display dialog "Hi. How are you doing?" buttons {"Good."} default button 1

I could then set x to this value:

set x to display dialog "Hi. How are you doing?" buttons {"Good."} default button 1

Now, as long as I don’t set x to anything else, I could use {button returned:“Good.”} from x the WHOLE script (not exactly).

thanks Dylan!
that was cool and makes sense :lol: