#!/bin/bash

PREFIX=$1

if [ -n "$PREFIX" ]
then
  PREFIX="WHERE path LIKE '${PREFIX}%'"
fi

sqlite3 ~/.DeDupe.sqlite "SELECT hex(checksum),path FROM (SELECT * FROM files WHERE checksum IN (SELECT checksum FROM (SELECT checksum, COUNT(*) as num FROM files ${PREFIX} GROUP BY checksum) WHERE num >= 2)) ${PREFIX} ORDER BY size;"
