Re: recursive folder count
Re: recursive folder count
- Subject: Re: recursive folder count
- From: Christopher Nebel <email@hidden>
- Date: Mon, 3 Mar 2008 09:55:52 -0800
On Feb 29, 2008, at 9:27 PM, Christopher Nebel wrote:
On Feb 28, 2008, at 10:06 PM, Peter Baxter wrote:
set sourceFolder to choose folder
tell application "Finder"
set filecount to (count (get entire contents of sourceFolder))
display dialog "There are: " & filecount & " files"
end tell
... Just remove the "get" (you can ditch the parentheses, too,
though they don't hurt anything), and it'll be nearly as fast as the
shell.
Unless I accidentally leave out a couple of critical details, in which
case it won't work at all. =/
1. Finder will refuse to get the entire contents of an alias object,
such as is supplied by "choose folder". You have to say "of *folder*
sourceFolder".
2. Finder will happily count "entire contents of ...", but returns 0.
If you say "*files of* entire contents of ..." (or "folders of", or
"items of", depending on what you want), then you'll get the right
answer.
To sum up:
set sourceFolder to choose folder
tell application "Finder"
set filecount to count every file of entire contents of folder
sourceFolder
display dialog "There are: " & filecount & " files"
end tell
This works for me in both Tiger and Leopard.
--Chris Nebel
AppleScript Engineering
_______________________________________________
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