• 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
recursive folder count
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

recursive folder count


  • Subject: recursive folder count
  • From: Tim Piper <email@hidden>
  • Date: Thu, 28 Feb 2008 20:19:39 +0000

Hi folks.

I need to count the number of items in folders recursively

but this only does the 1st level:

------------

set target_folder to choose folder with prompt "Choose target folder to clean"
tell application "Finder"
set filecount to count item target_folder
end tell
display dialog "There are:" & filecount & " files"

----------

now I know your going to say use a 'do shell' something like:

---------
set target_folder to choose folder with prompt "Choose target folder to clean"
set posixfolder to POSIX path of target_folder
set filecount to do shell script "ls -l " & quoted form of posixfolder & " | wc -l | awk '{print $1}'"
display dialog "There are:" & filecount & " files"


--------

but the problem here is the folder path selected may contain illegal 'shell' characters thus it breaks
the shell script.

suggestions....  speed is important here, so shell script is the preferred method.

thanks.







 _______________________________________________
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: Skeeve <email@hidden>
  • Prev by Date: Re: linebreak in a shell script; was Re: What's wrong with this call to zip?
  • Next by Date: Re: recursive folder count
  • Previous by thread: Re: Timing issues with Java executing AppleScript calling iTunes
  • Next by thread: Re: recursive folder count
  • Index(es):
    • Date
    • Thread