blob: ddfc36df25d0c1232ef3630b568562c9238b808b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
|