diff options
author | Yuchen Pei <id@ypei.org> | 2025-08-28 21:32:52 +1000 |
---|---|---|
committer | Yuchen Pei <id@ypei.org> | 2025-08-28 21:32:52 +1000 |
commit | 5d4e2e827dd0cb00db4e5de75eedff69df4bd7ff (patch) | |
tree | 7dc5cc83d94096716a23bffc5bef2f3f8e773e62 | |
parent | 569d7ebd177a3bc9274de130478adbba1e1e0d55 (diff) |
[bin] Adding a script that consolidates albums
-rwxr-xr-x | misc/bin/merge-tracks.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/misc/bin/merge-tracks.sh b/misc/bin/merge-tracks.sh new file mode 100755 index 0000000..ddfc36d --- /dev/null +++ b/misc/bin/merge-tracks.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Consolidate albums of < 3 tracks to a "medley" album + +find . -wholename './.git' -prune -o -type d -links 2 \ + -exec /bin/bash -c 'a=( "{}"/* ); [[ ${#a[*]} -lt 3 ]]' ';' -print | + while IFS=$'\n' read -r dir; do + for f in "$dir"/*; do + # echo "$f" + p1=$(echo "$f" | cut -d/ -f 2) + p2=$(basename "$f") + if [[ "$p1" == "Various Artists" ]]; then + newf="./Various Artists/Medley/$p2" + else + newf="./Various Artists/Medley/$p1-$p2" + fi + git mv "$f" "$newf" + done + done + +# May need to do multiple times to remove all empty dirs +find . -wholename './.git' -prune -o -type d -empty -print | + while IFS=$'\n' read -r dir; do + echo rmdir "$dir" + done |