dotfiles/.local/bin/scripts/downloads-qobuz

21 lines
754 B
Plaintext
Raw Normal View History

2024-06-28 19:32:19 +00:00
#!/bin/sh -ex
# Unpack and sort downloaded qobuz archive
# Obsolete through qobuz-dl
# Execute in target directory or with that as parameter
target="${1:-$PWD}"
archive=$(find $DATA/5* -maxdepth 2 -name Qobuz-commandes.tar)
cd $(dirname "$archive")
mkdir -p qobuz
cd qobuz
tar xf ../Qobuz-commandes.tar
mv -v ../*.jpg . || true
cd ..
mv -v qobuz $target/ #$d4/music/Worship/
rm -i Qobuz-commandes.tar
cd $target/qobuz
find -type d -exec sh -c 'test $(ls "{}" | wc -l) -eq 1 && find "{}" -maxdepth 1 -type f | xargs -i% mv -v % .' \;
find -type d -empty -delete
formatsongs
find -maxdepth 1 -name "*.jpg" -exec sh -c 'mv -v "{}" "$(echo {} | rev | cut -d"/" -f1 | rev | cut -d"-" -f1-2 | tr -s "-" " " | xargs -i% find -type d -iname "%*")/"' \;
exec zsh