• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: recursive folder count
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
echo email@hidden@nl | tr a-z@. p-za-o.@

 _______________________________________________
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

References: 
 >Re: recursive folder count (From: Christopher Nebel <email@hidden>)

  • Prev by Date: Re: recursive folder count
  • Next by Date: XML to AppleScript Record
  • Previous by thread: Re: recursive folder count
  • Next by thread: XML to AppleScript Record
  • Index(es):
    • Date
    • Thread