a little help with find and directory path for application

Just a little backgroud, I have a library of mp3 files in the following structure: /mp3/artist/album/track.mp3
Also contained in each album directory is a cover.jpg which contains the cover art file for that particular album.

I want to add the cover.jpg to the mp3 tag and have been using eyed3 to do this, but would now like to batch process the entire library. Here is the command syntax I have been using:

find -type f -name "*.mp3" -exec eyeD3 --add-image=cover.jpg:FRONT_COVER {} \;

The problem is that the find command only passes the mp3 file name to the eyed3 command and without the directory path the cover.jpg is not found.

either there is something simple I need to add to the line or create a bash script with variables (this is beyond my abilities :frowning: )

Thanks for any help!

Are you sure your find command works?
it should be like this :

find /mp3/artist -type f -name "*.mp3"  .......

Change your path to whatever you think of being appropriate.
The output should be absolute path in that case.

Never thought of using a "for" loop?

I am not sure why find is not passing in the path to the file. You can check what is being exec'ed with:

find -type f -name "*.mp3" -exec echo eyeD3 --add-image=cover.jpg:FRONT_COVER {} \;

Now if any of your directories or filenames contain spaces, you need to quote the filename argument:

find -type f -name "*.mp3" -exec eyeD3 --add-image=cover.jpg:FRONT_COVER \'{}\' \;

Alternatively, you can used man xargs (linux):

find -type f -name "*.mp3" --print0 | xargs -0 -n 1 eyeD3 --add-image=cover.jpg:FRONT_COVER

Hope this helps.

Thanks for your replies. I am running this command from the ~/mp3 directory
ludwig: I thought your second suggestion might solve the problem but instead of not finding the cover.jpg file I am now getting the track.mp3 file not found:

/media/ExtHDD/mp3 $ find -type f -name "*.mp3" -exec eyeD3 --add-image=cover.jpg:FRONT_COVER \'{}\' \;
File Not Found: './a-ha/Headline and Deadlines - The Hits of a-ha/Cry Wolf.mp3'
File Not Found: './a-ha/Headline and Deadlines - The Hits of a-ha/Crying in the Rain.mp3'
File Not Found: './a-ha/Headline and Deadlines - The Hits of a-ha/Early Morning.mp3'
blah, blah ......

I think the problem is the leading ./ How do I get rid of that?

For the xargs line I get:

/media/ExtHDD/mp3 $ find -type f -name "*.mp3" --print0 | xargs -0 -n 1 eyeD3 --add-image=cover.jpg:FRONT_COVER
find: unknown predicate `--print0'

Usage
=====
  eyeD3 [OPTS] file [file...]

eyeD3: error: File/directory argument(s) required

The solution is in post #2.
You must specify a start directory for "find" .

Yeah, I worked that out!

Right, suddenly twigged what's going on, the command works if the path for the cover.jpg is included but this will obviously vary according to album. So basically what I need is to create a variable for the album path and pass it to the eyeD3 command so that it looks like:

eyeD3 --add-image='/media/ExtHDD/mp3/artist/album/cover.jpg':FRONT_COVER '/media/ExtHDD/mp3/artist/album/track.mp3'

I thought so as well, but the linux version of man find (linux) has path as an optional argument. A bit of a surprise to me.

I also tried -execdir as this is supposed to execute the command from the directory where the file is, but still no luck?

~ $ find /media/ExtHDD/mp3 -type f -name "*.mp3" -execdir  eyeD3 --add-image=cover.jpg:FRONT_COVER \'{}\' \;
File Not Found: './Cry Wolf.mp3'
File Not Found: './Crying in the Rain.mp3'
File Not Found: './Early Morning.mp3'

:wall:

Would it be possible to use the printf %h to specify the path?
Thanks