Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been trying to establish a way to retrieve the folder size of around 5000 folders, which are contained in a folder with a total of around 15000 folders.

So for example:

Parent folder
   -- SubFolder
   -- SubFolder2
   -- SubFolder3
   -- SubFolder4

I only want to retrieve the folder size of SubFolder3 and SubFolder4 ... on a small scale this is of course trivial. When we're dealing with thousands it becomes a little more complex.

I had hoped that using something like unixkit-tiny with:

du -k --max-depth=1 < folderlist.txt | > foldersizes.txt

Would work, but that command sadly ignores the input - although the output works just fine.

share|improve this question
up vote 3 down vote accepted

If you're going to use unix tools:

xargs -L1 du -k --max-depth=1 <folderlist.txt >foldersizes.txt

Remember, unix commands tend to do one job. The job of du is to total file sizes. The job of xargs is to read a list of lines from a file.

By the way, did you really mean --max-depth=1, i.e., show the size of each subdirectory of the directories listed in folderlist.txt but don't detail their subdirectories? More commonly used options are -s (show the size of the listed directories, don't detail their subdirectories) and -S (don't include the size of subdirectories).

share|improve this answer
    
That's perfect. My unix command line is a little shaky so thanks for the clarification - very very helpful. You were also spot on with -s over --max-depth. Really hope this helps other folk in the future as I bashed (no pun intended) my head against this for about an hour earlier :) – foxed Jul 28 '10 at 20:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .