Best means to resolve/ present a tree of images arranged by dimension

I've obtained a deep directory tree containing.PNG documents. I would certainly such as to find all the.PNG documents in the directory, type them in order of dimension from tiniest to biggest, and afterwards present every 50th photo.

(I'm assessing information and also searching for the most effective dimension cutoff in between "possibly valuable" and also "arbitrary sound" so I desire a very easy means to glance these hundreds of images)

Any scripting aid is valued. I recognize just how to make use of 'find' to look by dimension, yet not just how to arrange the outcomes or run a display screen program to present every 50th without having it stop the procedure waiting.

I am making use of MacOS Snow Leopard, btw.

Many thanks!

0
2019-05-13 05:40:53
Source Share
Answers: 3

Just incorporate find to look for *.png, ls or stat to get the documents dimension, sort to type by documents dimension and also awk to publish just every 50th line.

0
2019-05-17 19:20:15
Source

Is that dimension as in documents dimension, or dimension as in photo measurements?

In zsh, to see all .png documents in the existing directory site and also its subdirectories, arranged by raising documents dimension:

echo **/*.png(oL)

There is no hassle-free chunk qualifier for ordering every N documents. Below is a loop that establishes the array $a to have every 50th documents (beginning with the biggest).

a=() i=0
for x in **/*.png(OL); do
  ((i%50)) || a+=$x
  ((++i))
done
my-favorite-image-viewer $a

Without zsh or GNU find, there is no very easy means of arranging find result by metadata (there is find -ls or find -exec ls or find -exec stat, yet they could not collaborate with documents having non - personalities, so I do not such as to advise them). Below is a means to do it in Perl.

find . -name '*.png' |
perl -e '
    $, = "\n";  # separate elements by newlines in the output
    print  # print…
        sort {-s $a <=> -s $b}  # …sorted by file size…
            map {chomp;$_} <>  #…the input lines (with the newline bitten off)
'

And below is a means to watch every 50th documents (beginning with the biggest):

find . -name '*.png' |
perl -e '
    $, = "\n";
    exec "my-favorite-image-viewer",
        map {$i++ % 50 ? () : $_}  # every 50
            sort {-s $b <=> -s $a} map {chomp;$_} <>
'

Another strategy would certainly be to create symbolic web links in a solitary directory site, with names gotten by documents dimension. In zsh:

mkdir tmp && cd tmp
i=1000000  # the extra 1 on the left ensures alignment
for x in ../**/*(oL); do
    ((++i))
    ln -s $x ${i#1}.png
done

With Perl:

mkdir tmp && cd tmp
find .. -name '*.png' |
perl -e '
    $, = "\n";
    for $x (sort {-s $a <=> -s $b} map {chomp;$_} <>) {
        symlink $x, sprintf("%06d", ++$i);
    }
'
0
2019-05-17 19:11:08
Source

If you do not have GNU devices or if your filenames have great deals of unique personalities, I would certainly make use of among Gilles' excellent solutions.

Nonetheless, below is one remedy making use of GNU find, sort, cut and also awk - - primarily the set of devices that alex suggested:

$ find -iname "*.png" -exec ls -s {} + | sort -n | cut -d" " --complement -f1 | awk '{ if ( NR % 50 == 0 ) print}' | xargs -d"\n" eog

Here I've made use of eye-of-gnome (eog) as the photo visitor, primarily due to the fact that it was just one of minority I can find that take numerous command line debates and also does something reasonable with it.

I'm certain one can remove the sort and also the cut for some even more awk code. To be entirely straightforward, I'm not exactly sure just how this remedy will certainly connect with whitespace.

0
2019-05-17 19:06:18
Source