2022-05-19 10:20:16 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Delete files under current or given path which exist elsewhere as listed in the locate database
|
2022-05-19 20:24:44 +00:00
|
|
|
# Matches first by name, then by checksum (currently inefficiently via md5)
|
|
|
|
find "$@" -size +50M -type f | while read filepath
|
|
|
|
do target="$(basename "$filepath" | synct-unarchive)"
|
2022-05-19 10:20:16 +00:00
|
|
|
highlight "$filepath"
|
2022-05-19 20:24:44 +00:00
|
|
|
locate -b "$target" | while read existing
|
|
|
|
do test "$(realpath "$target")" != "$(realpath "$existing")" -a -f "$existing" -a "$(md5sum "$existing" | cut -d\ -f1)" = "$(md5sum "$filepath" | cut -d\ -f1)" && echo "Found duplicate at $existing" && rm -vi "$filepath" && break
|
|
|
|
done
|
2022-05-19 10:20:16 +00:00
|
|
|
done
|