• 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: 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
  • Follow-Ups:
    • Re: recursive folder count
      • From: Philip Aker <email@hidden>
  • Prev by Date: Re: Safari - email contents
  • Next by Date: Re: recursive folder count
  • Previous by thread: Re: indesign hide panels
  • Next by thread: Re: recursive folder count
  • Index(es):
    • Date
    • Thread