There is a bash script that I use to extract the artwork from MP3 files before converting them.
#!/bin/bash
MUSIC_FILE=$1
IMAGE_FILE=""
TIMESTAMP=$2
if [ -z "$MUSIC_FILE" ] ; then
exit 2;
fi
if [ -z $TIMESTAMP ] ; then
TIMESTAMP=$(date +%s)
fi
IMAGE_FILE=`/usr/bin/eyeD3 --write-images=. "$MUSIC_FILE" 2>&1 | grep Writing | sed -e 's/Writing //g' -e 's/\.\.\.//g' | tr ' ' '_'`
if [ -z $IMAGE_FILE ] ; then
exit 3
fi
if [ -e $IMAGE_FILE ] ; then
/usr/bin/convert $IMAGE_FILE $TIMESTAMP.png
exit 0
else
exit 4
fi
The artwork file is well extracted, I can see it by a ls output, and the variable used to get the file name is correct (no heading/trailing spaces, etc), but within the script nor convert nor any additional ls finds it (no such file or directory)…
It really drives me nut…
Additional information : when I launch the script with the -x flag, every representation of my file name is yellow-colorized, can’t figure out why…
Thanks for your help !
Jérémie
Instead of trying to obtain filename by filtering command’s output, why did you not:
Not tested, but could work… ( approx 😉