dotfiles/.local/bin/scripts/cleandl

9 lines
299 B
Plaintext
Raw Normal View History

2023-03-13 14:36:09 +00:00
#!/bin/sh -e
# Clean the download folder of empty files and duplicates
IFS='
'
find -name '*([0-9])*' -exec sh -c 'file="{}";
new="$(echo $file | sed "s| \?([0-9])||")";
mv -v$(test -s "$new" && ! command diff "$file" "$new" >&2 && echo i) "$file" "$new"' \;
find -name "*.part" -exec rm -vi {} +