a little help with find and directory path for application


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting a little help with find and directory path for application
# 1  
Old 12-16-2011
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:

Code:
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 :-( )

Thanks for any help!
# 2  
Old 12-16-2011
Are you sure your find command works?
it should be like this :

Code:
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.
# 3  
Old 12-16-2011
Never thought of using a "for" loop?
# 4  
Old 12-16-2011
I am not sure why find is not passing in the path to the file. You can check what is being exec'ed with:
Code:
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:
Code:
find -type f -name "*.mp3" -exec eyeD3 --add-image=cover.jpg:FRONT_COVER \'{}\' \;

Alternatively, you can used xargs:
Code:
find -type f -name "*.mp3" --print0 | xargs -0 -n 1 eyeD3 --add-image=cover.jpg:FRONT_COVER

Hope this helps.
# 5  
Old 12-16-2011
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:
Code:
/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:
Code:
/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

# 6  
Old 12-16-2011
The solution is in post #2.
You must specify a start directory for "find" .
# 7  
Old 12-16-2011
Quote:
Originally Posted by methyl
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:
Code:
eyeD3 --add-image='/media/ExtHDD/mp3/artist/album/cover.jpg':FRONT_COVER '/media/ExtHDD/mp3/artist/album/track.mp3'


Last edited by barrydocks; 12-16-2011 at 11:13 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

What is the difference ../directory path and ./directory path in ksh?

What is the difference ../directory path and ./directory path in ksh? (1 Reply)
Discussion started by: TestKing
1 Replies

2. UNIX for Beginners Questions & Answers

Convert Relative path to Absolute path, without changing directory to the file location.

Hello, I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
Discussion started by: Sekhar419
4 Replies

3. Shell Programming and Scripting

Find if a directory exist from a list of the path

Hello, i want to script on sh to check from a path if the directory exist and isn't empty. I explain: path is : /aaa/bbb/ccc/ccc_name/ddd/ Where the cccc_name is in a list, so i think it's $1 My command find -name /aaa/bbb/ccc/$1/ddd/ didn't work because my $1 is the same and not... (5 Replies)
Discussion started by: steiner
5 Replies

4. UNIX for Dummies Questions & Answers

Find command fails when a space is in the directory path variable

I have a script like this running under OS X 10.8. The problem arises when the find command encounters a space in the path name. I need the "dir" variable as I'll be extending the script to more general use. #!/bin/bash CFS=$IFS IFS=$(echo) set dir = "/Users/apta/Library/Mail\... (3 Replies)
Discussion started by: apta
3 Replies

5. Shell Programming and Scripting

Find file and zip without including directory path

Does anyone know of a way to zip the resulting file from a find command? My approach below finds the file and zips the entire directory path, which is not what I need. After scanning the web, it seems to be much easier to perform gzip, but unfortunately the approach must use zip. find `$DIR`... (5 Replies)
Discussion started by: koeji
5 Replies

6. Shell Programming and Scripting

"find . -printf" without prepended "." path? Getting path to current working directory?

If I enter (simplified): find . -printf "%p\n" then all files in the output are prepended by a "." like ./local/share/test23.log How can achieve that a.) the leading "./" is omitted and/or b.) the full path to the current directory is inserted (enclosed by brackets and a blank)... (1 Reply)
Discussion started by: pstein
1 Replies

7. UNIX for Advanced & Expert Users

Find exact path of a file/directory

Hello Folks, A wrapper takes an argument of file or directory name. I want to allow paths that reside within the current directory only. Can simply discard the paths like "/A" & "../" as they go outside the current by looking at the path beginning. How to validate this one: A/../../../b... (4 Replies)
Discussion started by: vibhor_agarwali
4 Replies

8. Shell Programming and Scripting

Retrieve directory path from full file path through sh

Hi, I have a file abcd.txt which has contents in the form of full path file names i.e. $home> vi abcd.txt /a/b/c/r1.txt /q/w/e/r2.txt /z/x/c/r3.txt Now I want to retrieve only the directory path name for each row i.e /a/b/c/ /q/w/e/ How to get the same through shell script?... (7 Replies)
Discussion started by: royzlife
7 Replies

9. UNIX for Dummies Questions & Answers

how to find a path within unix root directory

I need to know whether nyfile/mypath exists on the file system in the root directory. How to do this (1 Reply)
Discussion started by: ramky79
1 Replies

10. UNIX for Dummies Questions & Answers

Question about Restricting Search path of FIND to current directory

Hi, By default FIND command searches for matching files in all the subdirectories within the specified path. Is there a way to restrict FIND command's search path to only the specified directory and NOT TO scan its subdirectories. Any help would be more than appreciated. Thanks and Regards (2 Replies)
Discussion started by: super_duper_guy
2 Replies
Login or Register to Ask a Question