I have a music collection of the structure Interpret -> Album -> song1.m4a song2.m4a cover.jpg
I can use ffmpeg to add the cover.jpg to the files:
#! /bin/bash
COVER=./cover.jpg
if test -f "${COVER}"
then
for f in ./*.m4a
do
echo "Adding ${COVER} for ${f}"
mv ${f} tmp.m4a
ffmpeg -i tmp.m4a -i ${COVER} -map_metadata 0 -map 0 -map 1 -acodec copy ${f} && rm tmp.m4a
done
else
echo "No ${COVER} found. Aborting..."
fi
How can I modify my script to do that?
What it does: when there is a cover.jpg in the folder, then add this folder lossless to all m4a audio files.
BUT: It seems that this does not work for all folders. It would be nice to just cd to the main music folder instead of going to every album folder and run the script above by hand.
What it should do:
- go to every subfolder
- if there is a cover.jpg file then proceed at 3. if not go to step 1. (next subfolder)
- for every m4a in this folder embed the cover.jpg into every m4a file in this subfolder