There are plenty of utilities (GUI, such as filelight and TUI, such as dua as well) for analyzing disk usage by space, but I would like to view my folders based on the count of files, as I’m making backups, and folders with lots of small files (e.g. node_modules) take very long to move around, so I guess that I’d be better of compressing those into a single file before archiving, as it’s already highly unlikely that I’ll need to access them anyway. Thanks for any pointers in advance!

  • palordrolap@kbin.social
    link
    fedilink
    arrow-up
    0
    ·
    9 months ago

    Cinnamon’s Nemo (GUI) file manager shows folder item count in the List View’s “Size” column rather than a byte value. It started as a fork of Nautilus (now GNOME Files), so that and its descendents may also have the same feature.

    The equivalent GNOME gio list command line command doesn’t seem to do this.

    It wouldn’t be too hard to whip something up in Python, Perl etc. if you can’t or don’t want to install anything else for some reason.

    e.g.

    perl -wle '$a=$ARGV[0];opendir D, defined $a && -d $a?$a:".";@x=readdir D; print -2+@x'
    
    

    is a Perl incantation that will return the number of entries in the current directory, or the supplied directory if that’s added as a parameter after the command.

    The -2 in there subtracts the count for . and ... That’s off by one for the root directory where there’s no “…” but that’s rare and I didn’t want to add too much for a quick proof of concept.