2022-10-24 20:22:45 +00:00
|
|
|
#!/bin/sh
|
2023-01-31 17:13:32 +00:00
|
|
|
# Delete files under current or given path
|
|
|
|
# which exist elsewhere as listed by locate.
|
|
|
|
# Args: [threshold (MB)] <filepaths...>
|
|
|
|
# OptDepends: synct (for checking against original filename)
|
2022-06-27 09:24:06 +00:00
|
|
|
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'"'
|
2022-05-26 06:53:35 +00:00
|
|
|
filepath="{}"
|
2023-01-31 17:13:32 +00:00
|
|
|
target="$(synct-unarchive "$filepath" || echo "$filepath")"
|
2022-05-19 10:20:16 +00:00
|
|
|
highlight "$filepath"
|
2022-05-26 06:53:35 +00:00
|
|
|
for existing in $(locate -b "$target")
|
2023-01-31 17:13:32 +00:00
|
|
|
do test -n "$(dupcheck "$target" "$existing") &&
|
|
|
|
echo "Duplicate found at $existing"
|
|
|
|
rm -vi "$filepath" && break
|
2022-05-26 06:53:35 +00:00
|
|
|
done' \;
|