MacOS – About this Mac – Storage information on terminal

macosstorageterminal

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 !

Best Answer

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.