# Find all directories by name
find . -iname 'porn' -type d
# Find all files in directories by name
find . -ipath '*/porn/*' -type f
# Find the top 10 largest directories
du -h porn | sort -h | tail -10
# ok, fine, that includes the top, make it 11...
# find mp4 files larger than 10G
find porn/ -size +10G -iname '*.mp4'
# delete mp4 files larger than 10G
find porn/ -size +10G -iname '*.mp4' -exec rm {} \;
or
find porn/ -size +10G -iname '*.mp4' -print0 | xargs -0 rm
# find all files, show their size(in KB), sort, show 10 largest
find porn/ -printf "%k %P\n" | sort -n | tail -10
# KB are too small, let's do MB
find porn/ -printf "%s %p\n" | awk '{print $1/(1024*1024) "MB",$2}' | sort -n | tail -10
# That failed on filenames with spaces... try again
find porn/ -printf "%s|%p\n" | awk -F\| '{print $1/(1024*1024) "MB",$2}' | sort -n | tail -10
#rename a bunch of files or directories
for i in porn* ; do mv "$i" "not$i" ; done
#rename a bunch of file extensions
for i in *.mp4 ; do mv "$i" "$(basename "$i" .mp4).txt" ; done
# test that thing first
for i in *.mp4 ; do echo mv "$i" "$(basename "$i" .mp4).txt" ; done
# Find files by contents
grep -riE 'sex.*sex.*sex' pornstories/
# A totally contrived example to find out how long each file is, there are far simpler ways to do this
find porn/ -iname '*,mp4' -print0 | xargs -0 ffprobe -show_entries stream -print_format json 2>/dev/null | jq .streams[0].duration
# Getting it to print the filename AND duration is left as an exercise for the reader.