Hi, I'd like to present my idea as a feature request for 'du' command. I've been asked several times to count certain file types within a given structure and present the data per each directory and in total (total size per each directory by counting given file types only). E.g. how many LibreOffice documents there are in /home directory, or how many archives are larger than 10MB, or how many video files etc. - and all lists should be sorted by size per each directory and in total.
Later on, I've noticed I am in constant need as well for analyzing my own file structure similarly, e.g. to list all images by size in order to check if there's any content that needs to be optimized. Find command has a power for some of those tasks, but mostly it seems like a perfect fit for "du --include", since "du --exclude" already exists. E.g. currently, du can tell me a disk usage for all types of content inside of each directory, but I can not filter out such reports only for certain content types that I need to monitor. I was looking for a tool to quickly achieve this, but surprisingly, there's nothing out there I could find that would suit those demands nicely. So, I created my own script. It's called wii: https://github.com/madjoe/wii It could resolve every single task I described from above and it serves me quite well almost on a daily basis now: *Examples:* # lists all image files recursively with individual stats per each subdirectory $ wii -i # lists all archives etc. $ wii -r # lists all custom file types $ wii -x "php css js" # integration of arguments that should be passed to find command $ wii -c "-type f -mtime -7 -size +2M -name '*log*'" A few use-cases: - 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 some PowerPoint documents as well. 1. $ wii -vd - You may assume that your archives and images are eating lots of disk space, so you need to check the structure recursively to see the exact numbers and make a decision which files to delete, or move to a different location. 1. $ wii -G0 -ri - You’d like to check very quickly how many PDF's are stored within multiple directories and how much of total disk space only those files occupy. 1. $ wii -x "pdf" - Before you upload a new version of your website, you may want to check if some of the images are too heavy and need to be optimized. 1. $ wii -G0 -i - Recently you updated your system and now you’d like to list all the files max. a week old that are larger than e.g. 30MB each. Also, you’d like to sum the results per each directory and see a total summary. 1. $ wii -c "-type f -size +30M -mtime -7" - In all of the examples from above, there would be “total” visible at the bottom of each list, where you could check how many of those files share the same filename, which may indicate unwanted duplicates. Please let me know what you think. Thanks in advance! Cheers, Jasmin Zainul