Formatting script that puts all the most important info in the file name

So I have had issues in the past with ID3 Tags becoming corrupted and with my ratings from iTunes being lost, so I decided to write a script a while back that would store all of the most important tags in the file name in an abbreviated format, just in case I'm on a machine that has limited space for file names. So if I ever lose tag info, I can just read everything back into its appropriate field from the file name.

For example, here's one file name:

1o1_2o2_Joris De Man & Julie Elven_~ST_Horizon Zero Dawn_5_Aloy's Theme (Part 1 - Motherland)_~IN.mp3

And this is the format

DiscXoYDiscs_TrackXoYTracks_Artist_AlbumArtist_Album_Rating_Title_Genre.mp3

The format also is convenient for mp3 players that play music by file names, since disc / track number are zero padded, so that file systems respect the ordering.

Also, notice the abbreviations. ~ST is Soundtrack. ~IN is Instrumental. You can enter whatever you like for these. I have several entered that are good for me. The more you enter, the more compact the names should be.

The script also does some standard formatting, such as capitalization, moving featured artists in the artist field, and separating artists by commas and a final ampersand. The artist is only included if different from the album artist, to save space. And I put my ratings in the title tag between asterisks, but you can make your own field for that if you want.

Don't know if this will do anyone any good, but just in case, figured I would share. Below are the contents of my FileConverstion.mta file, located in \Users\USERNAME\AppData\Roaming\Mp3tag\data\actions. Just create the file and paste the following into it to begin modifying it to you needs.

[#0]
T=1
F=_TAG
1=1
2={[(_-."

[#1]
T=5
1=$regexp(%album%,\\s+\\'['Disc \\d+\\']',,1)
F=ALBUM

[#2]
T=4
F=TITLE
1=(?:\\(|\\[)[Ff]eat\\.?(?:uring)? (.*?)(?:\\)|\\])
2=(Featuring \\1)
3=0

[#3]
T=5
1=$if($neql($strstr(%title%,'('Featuring ),0),%artist% $regexp(%title%,.*(Featuring .*?)\\')'.*,\\1),%artist%)
F=ARTIST

[#4]
T=4
F=TITLE
1= \\(Featuring .*?\\)
2=
3=0

[#5]
T=4
F=ARTIST
1= [Ff]eat\\.?(?:uring)?
2=,
3=0

[#6]
T=2
F=ARTIST
1= &
2=,
3=0|0

[#7]
T=4
F=ARTIST
1=, ([^,]*)$
2= & \\1
3=0

[#8]
T=4
F=TITLE
1=\\s*/\\s*
2= / 
3=0

[#9]
T=5
1=$if($eql($left(%title%,1),*),,** )%title%
F=TITLE

[#10]
T=5
1=$num($regexp(%discnumber%,(\\d+)/\\d+,$1),$len($regexp(%discnumber%,\\d+/(\\d+),$1)))o$regexp(%discnumber%,\\d+/(\\d+),$1)_$num($regexp(%track%,(\\d+)/\\d+,$1),$len($regexp(%track%,\\d+/(\\d+),$1)))o$regexp(%track%,\\d+/(\\d+),$1)_$if($eql(%albumartist%,%artist%),,%artist%)_~AARTIST_%album%_$regexp(%title%,\\*(\\d*)\\* (.*),$1_$2)_%genre%
F=COMMENT

[#11]
T=5
1=$replace(%comment%,: ,--,:,--,",~~,/,~-,%albumartist%,~AA,~AARTIST,%albumartist%)
F=COMMENT

[#12]
T=5
1=$replace(%comment%,East Coast Swing,~ECS,Argentine Tango,~AT,Cha Cha,~CC,Viennese Waltz,~VW,West Coast Swing,~WCS,Quickstep,~QS,Nightclub Two Step,~N2S,Two Step,~2S,Single Swing,~SS,Merengue,~MG)
F=COMMENT

[#13]
T=5
1=$replace(%comment%,Alternative,~AL,Big Band,~BB,Country & Folk,~CF,Instrumental,~IN,Christian,~CR,Christmas,~XM,Classical,~CL,Easy Listening,~EL,Electronic,~EC,New Age,~NA,Soundtrack,~ST,Traditional,~TR)
F=COMMENT

[#14]
T=5
1=$replace(%comment%,Anniversary,~AY,Anthology,~AN,Collection,~CN,Compilation,~CP,Edition,~E,National,~N,Orchestra,~O,Philharmonic,~PH)
F=COMMENT

[#15]
T=5
1=%comment%
F=_FILENAME

[#16]
T=4
F=COMMENT
1=.*
2=
3=0

iTunes does not write the ratings to the files and does not read them from the files.

Does your script cater for characters that are invalid for the underlying file system and has a markup scheme so that the special characters can be restored?

It would be interesting to know how it could happen that tags got corrupted but the rest of the file stayed ok.

IMHO: the way you posted the actions is rather unfriendly to read for me. It would be better to upload a zip-file with the action collection.

Yup, that I found was the issue with iTunes, and it's why I started prepending my ratings to the title field, since iTunes does in that case alter the file.

The script handles certain special characters in #11 of the script. For example, : is represented by -- and " is represented by ~~. Can add whatever you like instead. This is just what seemed logical to me on the spot.

Wouldn't mind uploading the script file, but I didn't see anything in the editor to allow for attachments. Easy enough to created it and cut and paste though.

see this post:

Both disc numbers and track number use zero padding up to the length of total discs / tracks. For example, if there are 20 discs and 200 tracks on a disc, you might have a track with the following:

01o20_001o200...

Some mp3 players rely on file names to sort things and without the zero padding you might find tracks starting with 1o200, 10o200, and 100o200 all sorted right next to one another since they all begin with 1 one. Zero padding solves this. This is only on files though. Doesn't inspect track titles.