Re: Finder can't count?
Re: Finder can't count?
- Subject: Re: Finder can't count?
- From: Steve Mills <email@hidden>
- Date: Wed, 16 Feb 2011 12:24:11 -0600
On Feb 16, 2011, at 12:06:33, Luther Fuller wrote:
> tell application "Finder"
> activate
> set folderAlias to (target of window 1) as alias
> set itemCount to (count items of folder folderAlias)
> set folderCount to (count folders of folder folderAlias)
> set fileCount to (count files of folder folderAlias)
If you're going to refer to a particular Finder object multiple times, why do you keep re-resolving it from an alias every time? Why not store a variable of the returned native type (folder, disk, etc), something Finder understands natively and presumably can resolve much faster?
set targ to target of window 1
set itemCount to (count items of targ)
set folderCount to (count folders of targ)
set fileCount to (count files of targ)
It's also much more clear to read and understand. Your script also assumes the target is a folder, which is why I changed the variable name to not use the term "folder".
Steve Mills
Drummer, Mac geek
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden