[chk_duplicate_imageid] Checks FLACs for duplicate IMAGEID

This commit is contained in:
ayakael 2018-12-29 16:37:42 -05:00
parent 20cdce0e9d
commit 435d8c0319
No known key found for this signature in database
GPG key ID: 575626A4AE5F4026

15
src/chk_duplicate_imageid Normal file
View file

@ -0,0 +1,15 @@
#!/bin/bash
chk_duplicate_imageid() {
local TARGET_DIR="${1}"
for flac in $(find ${TARGET_DIR} -name '*.flac'); do
echo ${flac}
local METADATA="$(print_meta_flac "${flac}")"
imageidList=($(awk 'BEGIN{RS=";";FS="="}{if($1=="IMAGEID"){print $2}}' <<< ${METATATA}))
if [[ ${#imageidList[@]} -ne 1 ]]; then
local NEW_METADATA="$(echo ${METADATA} | sed 's|;|;\n|g' | sed 's/.*IMAGE.*;//' | awk 'NF' | tr -d '\n')"
metaflac --remove-all-tags "${flac}"
tr ';' \\n <<< ${NEW_METADATA}| metaflac --import-tags-from=- "${flac}"
fi
done
}