blob: 0beab2860793f94a0964b8d8dcd3f62dad3b684d (
plain)
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
26
27
28
29
30
31
32
|
#!/bin/bash
# Loop through all FLAC files in the current directory
for file in *.flac; do
# Extract the ARTIST tag from the FLAC file using metaflac
artist=$(metaflac --show-tag=ARTIST "$file" | cut -d= -f2)
# Check if the ARTIST tag contains common delimiters for multiple artists
if [[ "$artist" == *"&"* ]] || [[ "$artist" == *","* ]] || [[ "$artist" == *"feat."* ]]; then
# Replace '&' with ',' to treat both as the same delimiter
artist=$(echo "$artist" | sed 's/&/,/g')
# Split the ARTIST string by ',' into an array of artists
IFS=',' read -r -a artists <<< "$artist"
# Trim leading/trailing spaces from each artist name
for i in "${!artists[@]}"; do
artists[$i]=$(echo "${artists[$i]}" | xargs) # Trim spaces
done
# Remove the existing ARTIST tag
metaflac --remove-tag=ARTIST "$file"
# Add each artist as a separate ARTIST tag
for artist_name in "${artists[@]}"; do
echo "Setting ARTIST to '$artist_name' for file '$file'..."
metaflac --set-tag=ARTIST="$artist_name" "$file"
done
else
echo "No combined artists found for '$file', skipping..."
fi
done
|