Adding Leading Zeros to File, Album & Directory Names


#1

Hello everyone,

If I wanted to locate and rename file & album names which include 1-9 in the title for song numbers and albums with many discs, how would I first filter to show only those and secondly, add leading zeros without messing up the remainder of the file/album/directory names?

I look forward to receiving your reply, thank you in advance.


#2

You can filter for fields with a single number with
%fieldname% MATCHES \d
To rename files and folders it is advisable to get the data in the tag fields correct and then rename the files. Please note that a number of characters are invalid for filenames or folders.
You can rename files and folders with actions of the type "Format value" or the functions in the Convert menu.


#3

Thank you for your reply. Let's use an example, there are two that I can think of. The first is Now That's What I Call Music.

I changed the track names so that they include the track number with no leading zero, then the song name, followed by the artist name in brackets. I then change the artist name in the artist and artists field from the true artist to Now That's What I Call Music because when I haven't done this in the past it has messed up my folder structure in Windows Media Player.

In this example, I would like to add a leading zero to the file name without adding a leading zero to the track number. I would also like to make sure that Vol. 02 appears this way, if it doesn't have a leading zero then one should be added. At the same time, I would need to avoid adding a leading zero to the Disc number. The same would apply to the directory.

Once this has been figured out I will mention the second example.

Thanks for your help.


#4

You can create a new filename (without touching the data in the tag fields) with:
Convert>Tag-Filename
Format string: $num(%track%,2)_%title%
(I would recommend a character other than the space character to separate the fields, e.g. the underscore. If you do not like it, the use whatever you want)


#5

Thanks for your reply, going back a step to get the filter right, how do I filter for 1-9?

Take the filename for example, how do I make it match files with 1-9?
%_FILENAME% MATCHES \d


#6

Have you tried it?
I mean: typing your post takes longer than testing it in MP3tag.


#7

Yes I did try it first, it came up with no results when there were loads of files with 1-9 in the filename.

Trying %_FILENAME% MATCHES 0\d instead brought up more likely results but also numbers from 10+ and not all tracks numbered 1-9 in the filename.

Considering that there are 182 discs, there should be 1,638 tracks found with the filter.


#8

If you want to filter for a number at the beginning, use
..... MATCHES "^\d"
If you want to filter for a single number at the beginning which is followed by a space character, use
..... MATCHES "^\d "
the dots stand for the fieldname.
All this and more is revealed in the help
http://help.mp3tag.de/main_filter.html


#9

Thank you, %_FILENAME% MATCHES "^\d " works well. I will go back to testing.


#10

That works well.

Filter
%_FILENAME% MATCHES "^\d "

Action
Format value
_FILENAME

Format string
$num(%track%,2) %title%


#11

Is it possible to filter by a number of words, which are listed and case sensitive? For example, I want to check that words such as 'the', to' and 'at' are lower case so I would like to find any which are upper case 'The', 'To' and 'At' so that I can correct it.


#12

%title% MATCHES "(?-i) The"
filters for " The"


#13

Brilliant, thank you. Is it possible to combine several so it searches for one or more like the examples I listed within one filter query?


#14

see the help on the filter options:
http://help.mp3tag.de/main_filter.html
(which I linked before)
Have a look at the descriptions for AND, OR and NOT