0

I wanted to loop through a folder containig .mp3 files and changing their album names (if they don't have one) to their title (e.g. Remix.mp3 with Title "Remix" gets the Album "Remix") using mp3agic.

This is my code so far:

if (mp3file.hasId3v1Tag()) {
    ID3v1 id3v1Tag = mp3file.getId3v1Tag();

    try {
        if (id3v1Tag.getAlbum().equals("")) {
            id3v1Tag.setAlbum(id3v1Tag.getTitle());
            mp3file.save(SAVE_DIR + "\\" + child.getName());
            System.out.println(SAVE_DIR + "/" + child.getName());
        } else {
            mp3file.save(SAVE_DIR + "/" + child.getName());
        }
    } catch (Exception e) {
        mp3file.save(SAVE_DIR + "/" + child.getName());
    }
}

I get the following error:

Exception in thread "main" com.mpatric.mp3agic.NotSupportedException: Packing Obselete frames is not supported at com.mpatric.mp3agic.ID3v2ObseleteFrame.packFrame(ID3v2ObseleteFrame.java:32) at com.mpatric.mp3agic.ID3v2Frame.toBytes(ID3v2Frame.java:83) at com.mpatric.mp3agic.AbstractID3v2Tag.packSpecifiedFrames(AbstractID3v2Tag.java:275) at com.mpatric.mp3agic.AbstractID3v2Tag.packFrames(AbstractID3v2Tag.java:261) at com.mpatric.mp3agic.AbstractID3v2Tag.packTag(AbstractID3v2Tag.java:227) at com.mpatric.mp3agic.AbstractID3v2Tag.toBytes(AbstractID3v2Tag.java:218) at com.mpatric.mp3agic.Mp3File.save(Mp3File.java:450) at de.thejetstream.main.Iterator.(Iterator.java:57) at de.thejetstream.main.Main.main(Main.java:12)

at this file:

name: Feel Good in Black and Yellow.mp3

title: Feel Good in Black and Yellow (feat. Gorillaz & De La Soul)

album: Black and Yellow - Single

It crashes at line 57, which equals to the last save (in the catch).

What is the problem with this code? Is it just because the file uses an old kind of codec or something like this?

JetStream
  • 809
  • 1
  • 8
  • 28
  • Think about this....Why do you need the try catch? If you need it then wouldn't you also need it for the **mp3agic.save()** method within the **catch**? Also, you should really always make sure you're catching the proper Exception(s). – DevilsHnd - 退職した Jul 03 '17 at 21:48
  • @DevilsHnd It's just a small program for bulk changing some music files and won't be used afterwards. Thats why I dont use proper Exceptions as it should just loop through some files. I think the corrupting file uses maybe an older codec for .mp3 and can therefore not be saved by mp3agic, but I'm not quite sure. – JetStream Jul 04 '17 at 07:02

1 Answers1

0

I found the solution:

The problem was that these files used ip3v2 tags instead of ip3v1. Simply checking which on it is and adjusting the code accordingly solved everything.

JetStream
  • 809
  • 1
  • 8
  • 28