Measuring disk usage of specific file types per each directory

I need your opinion on this: I just created a few lines of code in my bash script and I wonder if something like that should be integrated as (currently non-existing) du --include or it should remain as a completely separate project:

Check which images may need to be optimized (search for ALL common image formats).
wii v2.2.0 Demo

Check which particular scripts may need to be reduced in size.
wii v2.2.0 Demo

Check which recent files are eating up your space.
wii v2.2.0 Demo

The idea is to provide a tool that one could use when you know what you're looking for, but don't have any idea where it could be or what's the name of it. All you know is that you're looking for a video file somewhere within a certain directory tree, and there should also be tons of PowerPoint documents too.

Or, when assuming that your archives are eating lots of your disk space, but not sure where exactly. Or, when you need to check numbers very quickly of how many PDF's are stored within multiple directories within certain path and how much of total disk space those files occupy.

Or, when you just have to browse quickly through somebody else's data and would like to see a brief overview/summary of content types within each directory.


Are you kidding?
This is dope !!! Instantly adopted.

1 Like

Yes, I can see the potential use for this! I will add it to my collection of scripts, thank you :slight_smile:

1 Like

Wow. I'm glad that you like it. I find it quite useful for my everyday work, so I don't know how to proceed in order to share it with others, therefore I needed some help/feedback. Thanks, man. :wink:

1 Like

I will play more with it. For now it seem to do the job as advertised.
Never knew exactly this number
5583 ora
That's the number of drawings i did and saved in the past 10 years, just using MyPaint.

1 Like

I moved the topic to the Showcase category.

1 Like

It would be great to get some more feedback, since I basically just completed the bone structure of it.

LOL. I was surprised myself with similar findings. After those discoveries I freed up several gigs of disk space...

While i work i do save more iterations, but in the end just the sketch and the final i keep, and are not so big files. For instance this is a keeper :smiley:


1 Like

.profile is only for bash, new users have zsh (not possible to include)

but you can make both (include/script) in code ?

wii() {
    # your code
if [ "${BASH_SOURCE[0]}" == "$0" ]; then
    wii "$@"
    export -f wii

why not add optional search parameter ? without, sorry i don't see usage

1 Like

I just added the zsh support as per your suggestion, could you check it, please?

Should that be sufficient for zsh?

When you say "optional search parameter", do you think a regular search by pattern? I already have that in mind, it's not implemented yet, but it will be soon. Thanks! :slightly_smiling_face:

Wow, I would definitely need this at my work. Sadly I can only run windows there so no bash allowed.

I improved wii quite a bit and now it supports 3 independent modes of operation, including the Advanced mode - where you could set your arguments compatible with find.

With the newest additions, the tool became more versatile, e.g. by setting a parameter to -G flag, you could switch between grouping results by extensions vs. by actual filenames (new feature). Take a look at some of the examples within the current version 2.2.0:

Example 1: Advanced mode (-c)

$ wii -D 5 -F 3 -T 4 -c "-type f -mtime -7 -iname '*log*'"
[12.89MB] .config/chromium/Profile 1/Local Extension Settings/gighmnpiopklfepjosnamgckbiglidom
  12.88MB 041367.log
    8.5KB LOG
    4.5KB LOG.old
[4.984MB] .local/share/TelegramDesktop/tdata/user_data/cache/0
  4.984MB binlog
[ 3.25MB] .config/Rambox/Partitions/whatsapp_1/IndexedDB/https_web.whatsapp.com_0.indexeddb.leveldb
  3.238MB 013778.log
    8.5KB LOG
    4.5KB LOG.old
[2.898MB] .config/chromium/Profile 1/Local Extension Settings/ghbmnmjobekpmoecnmnilmnbdlolhkhi
  2.891MB 000007.log
    4.5KB LOG.old
    4.5KB LOG
[2.684MB] .config/chromium/Profile 1/Extension State
  2.676MB 007638.log
    4.5KB LOG.old
    4.5KB LOG
[34.62MB] total
  12.88MB 041367.log (1)
  6.941MB 000007.log (24)
  5.164MB binlog (2)
  3.238MB 016779.log (1)

-D 5: list max. 5 largest directories
-F 3: list max. 3 largest files per each directory
-T 4: list max. 4 largest accumulated sizes of files (grouped by filenames) in total summary
-c "-type f -mtime -7 -iname '*log*'": arguments for find: list all files that are max. 7 days old and contain log inside their names

Example 2: Predefined extensions

$ wii -C 0 -G 1 -D 0 -F 0 -T 5 -S 0 -avd
[36.43GB] total
     4672 txt
      512 mp4
      354 pdf
      333 mp3
      138 csv

-C 0: don't use colors for output
-G 1: group results by extensions
-D 0: don't list directories
-F 0: don't list files (by extensions) per each directory
-T 5: list max. 5 largest accumulated file sizes (by extensions) in total summary
-S 0: don't use a spinner
-avd: list all audio, video and document files

Example 3: Predefined extensions

$ wii -C 0 -G 0 -D 0 -F 0 -T 5 -S 0 -avd
[36.43GB] total
  1.542GB project_yachts_intro.m4v (1)
  476.4MB 20190527_120808.mp4 (1)
  465.2MB 20200322_101232.mp4 (2)
    322MB 20200101_000948.mp4 (2)
  310.6MB 20200701_164008.mp4 (1)

Similar as per previous example, only one parameter has been changed:
-G 0: group results by filenames
We may notice there are multiple files found within the structure that use the same filename.

Example 4: Custom extensions (-x)

$ wii -G 0 -D 5 -F 1 -T 5 -x "pdf odt"
[2.723MB] projectA/sites/default/files
  2.723MB Certificate_of_Completion.pdf
[2.723MB] projectB/sites/default/files
  2.723MB Certificate_of_Completion.pdf
[1.637MB] projectC/library/ezcomponents/Document/docs
  584.5KB 04_02_create_pdf_styled.pdf
[1.637MB] projectD/library/ezcomponents/Document/docs
  584.5KB 04_02_create_pdf_styled.pdf
[7.219MB] total
  4.945MB Certificate_of_Completion.pdf (2)
  1.641MB 04_02_create_pdf_styled.pdf (2)
  1.633MB 04_01_create_pdf.pdf (2)

-G 0: group results by filenames
-D 5: list max. 5 largest directories
-F 1: print largest file per each directory
-T 3: list max. 3 largest accumulated files (by filenames) in total summary
-x "pdf odt": search only for *.pdf and *.odt files

I changed the name of the script, so the command is no longer, but it's a plain simple wii.

The examples from above are somewhat complicated, but simpler options are still available:

Example 5: Predefined extensions

$ wii -av
[9.453MB] abc
        2 mp3
[8.129MB] wav
       34 wav
[720.5KB] mp3
       34 mp3
[17.79MB] total
       36 mp3
       34 wav

Calculates the size of all audio-video files and group them by extensions by default.

If you enjoy my work, please hit the star icon at the top on wii's GitHub page.
Feel free to share your ideas how to make it even better. Thanks!

Forum kindly sponsored by