From 289c583fbecf5b2271662b22098a3725161789d3 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Sat, 4 Nov 2023 19:10:15 +0100 Subject: [PATCH] bin: deduplication with rmlint and download handling --- .local/bin/scripts/dedup | 5 +++++ .local/bin/scripts/dedup-dox | 6 ++++++ .local/bin/scripts/dedup-images | 5 +++++ .local/bin/scripts/downloads | 20 ++++++++++++++++---- 4 files changed, 32 insertions(+), 4 deletions(-) create mode 100755 .local/bin/scripts/dedup create mode 100755 .local/bin/scripts/dedup-dox create mode 100755 .local/bin/scripts/dedup-images diff --git a/.local/bin/scripts/dedup b/.local/bin/scripts/dedup new file mode 100755 index 0000000..7f6f070 --- /dev/null +++ b/.local/bin/scripts/dedup @@ -0,0 +1,5 @@ +#!/bin/sh -e +rmlint --max-depth=5 --keep-hardlinked --rank-by=HpOdlam -o pretty -o sh:/tmp/dedup.sh "$@" +printf "Enter to confirm, any text to skip (answer does not matter if nothing was printed above this line) " +read -r answer +test -n "$answer" || /tmp/dedup.sh -d diff --git a/.local/bin/scripts/dedup-dox b/.local/bin/scripts/dedup-dox new file mode 100755 index 0000000..d383376 --- /dev/null +++ b/.local/bin/scripts/dedup-dox @@ -0,0 +1,6 @@ +#!/bin/zsh +# Deduplicate Documents +dox=$(realpath $DATA/3-*) +echo "Hardlinking:" +dedup --max-depth=9 -c sh:handler=hardlink "$dox" "$@" +dedup --max-depth=9 "$dox" "$@" diff --git a/.local/bin/scripts/dedup-images b/.local/bin/scripts/dedup-images new file mode 100755 index 0000000..73d08a7 --- /dev/null +++ b/.local/bin/scripts/dedup-images @@ -0,0 +1,5 @@ +#!/bin/zsh +# Deduplicate Images +img=$(realpath $DATA/4-*/images) +#find -type f -not -name '*.xmp' | rmlint -k - // pictorials +dedup --max-depth=9 -k $img $img/[a-z]*/ // $img/pictorials/stockicons/ $img/**/*.xmp "$@" diff --git a/.local/bin/scripts/downloads b/.local/bin/scripts/downloads index e014b50..9a699b9 100755 --- a/.local/bin/scripts/downloads +++ b/.local/bin/scripts/downloads @@ -1,8 +1,20 @@ -#!/bin/sh -e +#!/bin/sh # Move common files into their place from the downloads folder. -dow=$DATA/5-*/download -rmlint --rank-by=l -o pretty -o sh:/tmp/dow.sh *.* -printf "Enter to confirm, any text to skip. " +d5=$DATA/5-* +dow=$d5/download + +# Internal Duplicates +rmlint --rank-by=Olam -o pretty -o sh:/tmp/dow.sh $dow/*.* +printf "Enter to confirm, any text to skip (answer does not matter if nothing is printed above this). " read -r answer test -n "$answer" || /tmp/dow.sh -d + +# Songs mv -v -- $dow/*.mp3 $dow/*.flac $dow/*.wav $MUSIC/ +mv -v -- $dow/*.iso $DATA/4-*/flash/ + +# Data-dir duplicates +rmlint --keep-all-tagged --max-depth=5 --rank-by=Odlam -o pretty -o sh:/tmp/dow.sh $d5 // $DATA/1-* $DATA/2-* $DATA/3-* $DATA/4-* +printf "Enter to confirm, any text to skip (answer does not matter if nothing is printed above this). " +read -r answer +test -n "$answer" || /tmp/dow.sh -d