Custom Action to Reorganize a Music Library using Tag Information

This post is not a direct request for help but more of a How-To. I felt the need to do this post given the number of times I've seen people request help related to moving files from one directory structure to another using existing tag information. Most of the posts I read didn't appear complete. I'm not saying that this solution is the end-all for everybody but I believe it provides the basis whereby others can modify for their own particular use. However, before moving forward, let me start with this shameless plug.

I've been a big fan of Mp3tag for many years. It's saved me countless hours tagging and organizing all of my music files (both FLAC and MP3). I've donated to Florian in the past and will again soon, especially after this 3.00 release. I encourage everybody to do the same because Florian and his team do outstanding work and the user community is the best. It costs money to host this site, for purchasing development tools and to receive such excellent support so please donate.

This is my contribution for moving all the files contained within one folder/directory structure to another and reorganized based upon music file tag information. However, before discussing this specific solution, let me provide some background information.

ASSUMPTIONS:

  • The music files of interest are contained within the following working directory: C:\Users\Scott\Music\Working
  • All of the music files in the working directory, including any sub-folders within it, are properly named and tagged.
  • In addition to being properly named and tagged, music files in sub-folders may include cover art (e.g. folder.jpg).

GOALS:

  • I want to re-organize the music files in my working directory into a new destination directory as follows: C:\Users\Scott\Music\_Reorganized\Album Artist\[Year] Album\filename.ext
  • I don't want to use the built-in Convert Filename - Tag functionality. Instead, I want to create an action group.
  • I chose an action group so that (1) it'll work for any working directory, and (2) allows adding other actions at a later date.

Yeah, I know, that was a lot of information to digest. The good news is that the solution is actually fairly simple. So let's go through the steps I performed to achieve the goals stated above.

STEPS:

  1. Using the Action menu, I created a New action group called: Reorganize Music Library (WARNING - Moves && Deletes files)
  2. I then created a New action as follows:
    Action Type: Format value
    Field: _DIRECTORY
    Format String: $cutRight(%_workingpath%,$add($len(%_workingdir%),1))\_Reorganized\%albumartist%\'['%srcyear%']' %album%\
  • Please note that I have a user-defined tag called SRCYEAR (i.e. %srcyear%) where I store the Year when a specific Album from a specific Album Artist was released. You may need to modify this tag for your given situation.
  1. Finally, save this Action in the Action Group.

USAGE:
To reorganize the music files in the working directory:

  • If you're not already in the correct working directory, from the menu select File -> Change Directory. In the pop-up dialogue box, make sure (1) the Sub-directories checkbox is checked then (2) select the working directory: C:\Users\Scott\Music\Working
  • After a moment, all of the music files should become visible on the screen.
  • On the keyboard, select all music files using the shortcut: [CTRL] [A]
  • From the menu, select Actions -> Reorganize Music Library (WARNING - Moves & Deletes files)
  • After a moment, the "Writing tag data" pop-up window will disappear
  • DO NOT CLOSE Mp3tag, yet.
  • Your reorganized files should be located here: C:\Users\Scott\Music\_Reorganized

NOTES:

  1. If the reorganized files in the new directory are not what you are expecting, go back to Mp3tag and from the keyboard, use the shortcut [CTRL] [Z] to undo the action.
  2. After executing this script, all music files in the working directory that share the same Album Artist, Year and Album tag data will be relocated into a common destination directory. Therefore, any duplicate music, cover art or other file(s) from the original working directory will require a manual confirmation to overwrite EACH duplicate that's identified in the destination directory. Be cautious when using this script on directories containing a large quantity of files.
  3. The working directory will have empty folders that need to be removed manually. That's one of the Actions I will add to the Action Group at a later date.
  4. I had to do some "trickery" to get the destination directory to work correctly. In short, %_workingpath% is the full path to the Mp3tag working directory and $cutRight(%_workingpath%,$add($len(%_workingdir%),1)) puts me in the directory above.

Well, that's my solution for reorganizing directories based upon the tag information. Admittedly, this may not be the most elegant solution but it appears to be working properly from the testing I've run on it thus far. Feel free to use or modify what I provided but remember, you assume all risks;)

I've been very busy at work so I'm pressed for time. If anybody can enhance this action group to automatically remove empty directories from the working directory, you would have my gratitude!

1 Like