Re: Aliases of Files/Folders in a Folder
Re: Aliases of Files/Folders in a Folder
- Subject: Re: Aliases of Files/Folders in a Folder
- From: "Marc K. Myers" <email@hidden>
- Date: Mon, 05 Nov 2001 12:53:37 -0500
- Organization: [very little]
>
Subject: Re: Aliases of Files/Folders in a Folder
>
Date: Mon, 5 Nov 2001 07:48:43 -0700
>
From: Michelle Steiner <email@hidden>
>
To: <email@hidden>
>
>
On 11/5/01 6:19 AM, Joe Schmidt <email@hidden> wrote:
>
>
>I need to get the aliases of all files/folders within a folder, how do I go
>
>about doing that?
>
>
>
>Is there a way to "list files"
>
>
Very easy, actually.
>
>
set the FolderToList to choose folder
>
tell application "Finder"
>
set the FileList to files of the FolderToList --lists files only
>
set the FolderList to folders of the FolderToList --lists folders only
>
set the itemlist to items of the FolderToList lists all files and folders
>
end tell
>
>
Only the top level will be listed, though.
The only problem with this is that he'll end up with lists of Finder
references, not aliases. Try this instead:
set the theFldr to choose folder
tell application "Finder"
try
set fileList to (files of the theFldr) as alias list -- files
on error
set fileList to (files of the theFldr) as alias as list
end try
try
set folderList to (folders of the theFldr) as alias list -- folders
on error
set folderList to (folders of the theFldr) as alias as list
end try
try
set itemList to (items of the theFldr) as alias list -- files & folders
on error
set itemList to (items of the theFldr) as alias as list
end try
end tell
You have to use the "try...on error...end try" because there's a bug
that throws an error if there's a single alias in the resulting list.
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[11/5/01 12:52:42 PM]