So I have a folder of about 14K pictures and videos, and I decided to try to find the smallest images in my set (I was actually looking for the darkest ones, and it kinda worked). So I made up this command, and it works out nicely:
open $(find . | grep JPG | xargs ls -all | sed 's/ */ /g' | cut -f 5- -d' ' | sort -nr | tail -n 500 | cut -f 5 -d' ')
Logical steps:
open $(find . | grep JPG | xargs ls -all | sed 's/ */ /g' | cut -f 5- -d' ' | sort -nr | tail -n 500 | cut -f 5 -d' ')
Logical steps:
- find . : Shows all files inside the current directory, and recursively inside all subdirectories.
- grep JPG : Remove all no-JPG files from the list (folders, system files, video files, etc).
- xargs ls -all : Re-list all the files, this time with all file attributes (size, permissions, etc).
- sed 's/ */ /g' : Replace all space sequences with a single space.
- cut -f 5- -d' ' : Grab only the attributes starting from the file size column (this might vary depending on your ls default attributes. Tweak the "5" to accomodate your own settings).
- sort -nr : Sort descendingly by file size.
- tail -n 500 : Grab only the 500 last files (I didn't want to open ALL of them).
- cut -f 5 -d' ' : Grab only the actual filename (remove all other attributes).
- open : Open them in Preview! (Or whatever your default image-viewing application is).
- View!
No comments:
Post a Comment