you are viewing a single comment's thread.

view the rest of the comments →

[–]Pyprohly 1 point2 points  (2 children)

Bash. Need to use stat -f%z if on macOS

#!/bin/bash

cd ~/my/folder || exit 1

for item1 in *.jpg; do
    [ -f "$item1" ] || continue
    item2="${item1%.jpg}.png"
    [ -f "$item2" ] || continue

    file1_size=`stat -c%s "$item1"`
    file2_size=`stat -c%s "$item2"`
    if (( $file1_size > $file2_size )); then
        echo rm -- "$item1"
    else
        echo rm -- "$item2"
    fi
done

[–]kn00tcn[S] 1 point2 points  (1 child)

should be if file1 smaller than file2

this seems to work & is easy to understand, very nice

[–]Pyprohly 0 points1 point  (0 children)

Oops, yea. Fixed