0

I am trying to reproduce the About this Mac - Storage window in the terminal.

About this Mac - Storage window

Is there any easy way to do this ?

For the moment, the following commands are working (quite fast):

mdfind kind:music -0 | xargs -0 du -k | awk '{sum += $1} END {print sum}'

mdfind kind:image -0 | xargs -0 du -k | awk '{sum += $1} END {print sum}'

For the Applications, I use the metadata as du is way slower:

mdfind kind:application -0 | xargs -0 mdls -n kMDItemFSSize | awk '{sum += $3} END {print sum}'

When using the mdls -n kMDItemFSSize command on each application separately, it provides the same result as the Get Info window. However, when running the above command, I don't have the same result as the About this Mac - storage graph.

Also, I did not find any way to get the other types of data (movies, other, backups..)

Do you guys have any idea ?

Thanks !

1

Yeah try using something like this:

du /Application
du /apps

etc

Just use the path to where the files/folders of interest are. To find them you can use the grep/find and cat the results into a txt file or simply pipe the results into your du. Depends on where all your files/folders of interest are.

  • That is what I have been doing, but for the Application folder, the "du" command takes a very long time + the results are not consistent with the Storage tab.. Thanks for your answer though ! – zigoingoin Aug 3 '15 at 23:16
  • @zigoingoin I assume the inconsistency surfaces as a "total" less than you were expecting? Is this correct? – 1'' Aug 4 '15 at 10:08
  • In fact, I found the problem(s) for part of the question: 1. I forced spotlight to re-index the computer 2. The output is formatted in 512 bytes-blocks So the only remaining problem is how to compute the Application folder size FAST (and accurately). There is also the "other" tab, but I will use the df command and substract this with the other results – zigoingoin Aug 4 '15 at 13:46
  • @zigoingoin will put more thought into this question... please revisit this week. – 1'' Aug 11 '15 at 12:13

You must log in to answer this question.

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