Greg Artisi
Greg Artisi

Reputation: 172

java id3tag duplicate mp3 files

i work with the jid3tag librairy to modify metadata of mp3 files. when i save my modification, it duplicate the mp3 file creating a "songtitle.mp3" and a "songtitle.original.mp3" . my question is : how to modify a mp3 file without duplicate it?

here is my code:

TagOptionSingleton.getInstance().setDefaultSaveMode(TagConstant.MP3_FILE_SAVE_OVERWRITE);
    AbstractID3v2 id3v2= new ID3v2_4();
    // setup id3v2
    AbstractID3v2Frame frame;
    AbstractID3v2FrameBody frameBody;

    frameBody = new FrameBodyTIT2((byte) 0, "songTitle");
    frame = new ID3v2_4Frame(frameBody);
    ((AbstractFrameBodyTextInformation) frame.getBody()).setText(metatitle);
    id3v2.setFrame(frame);
    mp3file.setID3v2Tag(id3v2);
    try {
        mp3file.save();

        } catch (IOException | TagException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

thanks

Upvotes: 0

Views: 51

Answers (1)

Greg Artisi
Greg Artisi

Reputation: 172

Thanks, i didnt find solution.

so i just delete the file using Files class like this:

 try {
        mp3file.save(TagConstant.MP3_FILE_SAVE_OVERWRITE);
        String p = destFile.getPath();
        String[] s = p.split(".mp3");
        Path path = Paths.get(s[0]+".original.mp3");
        System.out.println(path);
        Files.deleteIfExists(path);

        } catch (IOException | TagException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

Upvotes: 1

Related Questions