Search code examples
c++11taglib-sharp

Taglib rename file on save


I'm trying to write a program that would let me modify the tags of mp3 files, to do this I'm using Taglib with c++11. I understood how to change the tags of a file but I'm not sure how (or even if) I can rename the file when saving it.

Let's say i have the following code:

TagLib::FileRef f("Vivaldi - La Primavera.mp3");
f.tag()->setTitle("La Primavera");
f.save();

This will change the title tag of the mp3 file (not the filename) to "La Primavera" leaving everything else unchanged. Is there a way to have the new file after the f.save() be called only "La Primavera" using only Taglib or do i have to do something like reading the file once more and rename it?
I've read Taglib's documentation but can't seem to find anything on the matter.


Solution

  • TagLib sharp isn't a tool to manage your file system. It's for reading and writing the various bits of meta data in media files (audio and video).

    In order to rename your files just use the normal methods for copying and deleting files.

    Open the original file, edit the meta data, release the file handle, copy to new filename and then finally delete the original file.