Hi. I created 100 dummy mp3s, and I used the id3tool to change the tags on them. Each mp3 is named some number with the extension of mp3 appended to it (ex: 20.mp3). When I click on the file, the tags that I changed appear. What I'm trying to do is only obtain the album name of the mp3 file.

I was told I could do this using grep and sed, but I am not sure how. I was thinking that I could use grep to locate the line that has the album name, but I just don't know how to extract it. An example I guess would be grep Album /home/Documents/id3tool 20.mp3 (this is where the id3tool is located). I think this works, but again, I don't know how to extract it.

The reason why I need to extract it is because I am writing a procedure to create sub-directories of the album names, and then sort the mp3 files. I have the files stored in a TESTMP3 directory. In the procedure, I plan to traverse through the files of that folder with a while loop and create a sub-directory with the Album name. Once the folder is made, I then plan to move the file, renaming it in the process, into the directory. Any thoughts would be greatly appreciated!

I'm not familiar with id3tool, but I imagine it grabs some metadata from the mp3 file. If that is the case, you could do something like:

id3tool 20.mp3 | grep Album

Store than in a variable and go from there. If you could post some commands that you are running with output, I'd be glad to help further.

Regards,
Tom

Thanks, it worked.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.