Today I collect several scripts for a program named mp3tag (Version 2.6.2):
Convert tags to filename
$validate([$left(%discnumber%,1)-][$num(%track%,2) - ]$if($grtr($len(%artist%),40),,[%artist% - ])%title%,-)
A short explanation
In Windows are restrictions to the filename, so you can not use several punctuation characters and the whole path should not be longer than 255 charaters at all. Both cases happened to me recently and I sovled the problems this way:
invalid characters like
:will be replaced by
-. This filters the invalid characters from used tags and prevents that the file become useless.
$if($grtr($len(%artist%),40),,[%artist% - ])With this here I check how long the artist name is – is it longer than 40 characters it will not be used in the filename.
Furthermore I expect there are any albums which contains more than nine CDs (
%discnumber%) so I only include only the first character. For the tracknumber I always expect a format desaster: sometimes it is like „2/18“, „02/7“, „2“ or „02“ Here I read only the first number from this tag and convert it always to two digits with a leading zero.