#!/bin/sh # Delete files under current or given path # which exist elsewhere as listed by locate. # Args: [threshold (MB)] # OptDepends: synct (for checking against original filename) case $1 in ([0-9]|[0-9][0-9]) threshold=$1; shift;; esac find "$@" -size +${threshold:-50}M -type f -exec sh -c "IFS=$'\n'"' filepath="{}" target="$(synct-unarchive "$filepath" || echo "$filepath")" highlight "$filepath" for existing in $(locate -b "$target") do test -n "$(dupcheck "$target" "$existing") && echo "Duplicate found at $existing" rm -vi "$filepath" && break done' \;