Re: recursive folder count
Re: recursive folder count
- Subject: Re: recursive folder count
- From: Philip Aker <email@hidden>
- Date: Mon, 03 Mar 2008 10:49:26 -0800
On 08-03-03, at 09:55, Christopher Nebel wrote: 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.
set targ to (path to desktop folder) as alias tell application "Finder" count of files of entire contents of targ end tell
Works for me in both Tiger and Leopard. However my desktops are not the same on the different systems.
Philip Aker |
_______________________________________________
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