• 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: Is there a shell tool to find folders greater than a given size?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there a shell tool to find folders greater than a given size?


  • Subject: Re: Is there a shell tool to find folders greater than a given size?
  • From: "Steven D. Majewski" <email@hidden>
  • Date: Sat, 1 Mar 2008 14:23:07 -0500


On Feb 28, 2008, at 11:32 PM, Mark J. Reed wrote:

The size of a folder (beyond the physical size of its directory list)
is not readily available in the shell.  Typically you use the "du"
(disk usage) command to add up how much space a folder's contents take
up.  You could pipe the result through awk to find the folders whose
size exceeds your threshold value...but you'd still have the list
management problem.  I think I'd stick with the Finder on this one.




I'm not sure that I understand what folks in this thread mean as the
'list management problem', but yes, a simple shell one liner is:


du FOLDER | awk -e '{ if ( $0 > 999 ) { print $2; }}'

where "999" above is size in disk blocks.  Substitute 'du -k FOLDER'
if you want to express size in Kbytes. The above just gives you
the list of folder pathnames -- if you want both the size and the
name, print the whole line with 'print $0' -- in which case, you
might want to also pipe it to sort to print the largest first:


du -k FOLDER | awk -e '{ if ( $0 > 999 ) { print $0; }}' | sort -rn


Wrapping the unsorted, pathname-only, size-in-K version in applescript:

property msize : 999

do shell script "du -k " & (POSIX path of (choose folder)) & " | awk - e '{ if ( $1 > " & msize & " ) { print $2; }}' "
every paragraph of result
choose from list result




( The 'choose from list' at the end is just to display the list --
  replace with whatever you need. )



-- Steve Majewski


On 2/28/08, Gary (Lists) <email@hidden> wrote:

Come forth, all ye Shellites, and tell your tales.

I have been working on this (AS) script that reports in HTML about folders
whose size is greater than some given size [*], in an hierarchical report.


I don't speak Shelliac [!], so it only just occurred to me that there might
be a command provided to do just that, but I have no idea how to know even
know that. [+]


Is there something shelly that reports back a list, with paths, of all
folders exceeding some size limit, given some start folder?


(I don't trust Spotlight one hoot, as it can't find items I can see with my
own eyes. Besides, I want a live find.)


Thanks.
--
Gary

[*]
The Finder does a fast and fine job of getting a list of big folders with
the command:


every folder of _someFolder whose physical size is greater than _someSize

The real work is just managing the list of hierarchical results, since I
only want to keep drilling down folders that exceed the limit, until there
are not any more folders that do...then I've found the folder(s)
contributing the weight.


[!]
Weren't they a species on Next Gen? I can't remember them very well. Blob
creatures? Telepathic or something? Talking to Troy in her mind? Or were
they the ultra-litigious species that Picard one-upped in that treaty trial?


[+]
Like knowing the definition of some concept, but having no idea if there's a
word, what the word is, or how it could possibly be spelled.
A very interesting human problem.



_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript- email@hidden)
Help/Unsubscribe/Update your Subscription:
40mail.com
Archives: http://lists.apple.com/archives/applescript-users


This email sent to email@hidden



--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript- email@hidden)
Help/Unsubscribe/Update your Subscription:
40virginia.edu
Archives: http://lists.apple.com/archives/applescript-users


This email sent to email@hidden

_______________________________________________ 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: Is there a shell tool to find folders greater than a given size?
      • From: Ed Stockly <email@hidden>
    • Re: Is there a shell tool to find folders greater than a given size?
      • From: Philip Aker <email@hidden>
  • Prev by Date: Re: Illustrator CS3 how to import graphic styles?
  • Next by Date: Re: Is there a shell tool to find folders greater than a given size?
  • Previous by thread: Re: Out of memory
  • Next by thread: Re: Is there a shell tool to find folders greater than a given size?
  • Index(es):
    • Date
    • Thread