Hello,
Can anybody help me please with some coding of a script?
I regularly download mp3 files using get_iplayer which I then play in my Humax set top box. I find the Humax will display an image for the file if the image is embedded within the mp3 file.
So I wrote a script to go through a folder and add the relevant image file. Here's my script :-
for FILE in *.mp3 do bname=$(basename "$FILE") extension="${bname##*.}" filenamewoext="${bname%.*}" imagefile="${filenamewoext}.png" echo adding cover image ... eyeD3 --add-image $imagefile:FRONT_COVER:Picture "$FILE"
echo Stripping any version 1 tags id3v2 --delete-v1 "$FILE" # Now for a tidy up and delete the original image file # search and add image img=$(id3v2 -l "$FILE" | grep -i "APIC") if $img =""; then echo "Adding the image failed" exit 1 else rm -f $imagefile fi
done
The problem comes in the tidy up section. I don't want to delete the image file if adding it has failed but even though I'm getting an error "mp3image.sh: line 47: APIC: command not found", the image is still being deleted.
I've tried various ways of writing this code and all have failed. Writing code is far from my strong point so would appreciate some pointers as to where I'm going wrong particularly since if I type out the img=.. command in a console, it seems to work and produces a line like this :- APIC (Attached picture): (Picture)[, 3]: image/png, 58900 bytes so adding the image did work.