IPB

Welcome Guest ( Log In | Register )

> Notice!

Please take a minute to check our Frequently Asked Questions. Use Search to reveal possible related topics.

Also make sure you've read the Forum Guidelines before posting in this forum.

 
Reply to this topicStart new topic
> Single Action for Auto Renumbering Tracks with a Leading Zero
ragtag
post Sep 8 2017, 12:14
Post #1


Member


Group: Full Members
Posts: 66
Joined: 16-February 13
Member No.: 17578
Mp3tag Version: 2.54



Hello Everyone smile.gif

So far, I have alternately applied the Auto-numbering Wizard and a Filename-to-Tag format string to renumber tracks to display a leading zero, for eg. 01, 02, 099. Now, skipping any one of these two methods, and using only the Filename Field:

If any number, and sample, of tracks, which almost invariably preceded by a track number in some format, are to be auto-renumbered to display the required leading zero in the Track Field, how will this be achieved through a single action? Is it possible to derive at a solution at all, in spite of the many different ways in which the track numbers are usually integrated with the Filename? To name but a few examples:

1 File Name
1. File Name
1 - File Name
01 File Name
01. File Name
01 - File Name
99 File Name
100 - File Name

Thank you for your assistance.
Go to the top of the page
 
+Quote Post
DetlevD
post Sep 8 2017, 14:45
Post #2


Member


Group: Full Members
Posts: 6634
Joined: 26-May 06
From: Wuppertal, Germany, Planet Earth
Member No.: 3194
Mp3tag Version: 2.84



QUOTE (ragtag @ Sep 8 2017, 13:14) *
...to display the required leading zero in the Track Field ...

Note: It is not required to format the TRACK field having any leading zero!
If I remember right, the file type MP4 does not like any leading zero digit at all within the TRACK tagfield.

Here is a formatstring, which get the leftmost number from the filename.
The result should be stored into the tagfield TRACK.

TRACK <== $regexp(%_filename%,'^0*(\d+)[\.\s\-]+(.+?)$','$1')

From:
1 File Name
1. File Name
1 - File Name
01 File Name
01. File Name
01 - File Name
99 File Name
100 - File Name

To:
1
1
1
1
1
1
99
100


DD.20170908.1545.CEST

This post has been edited by DetlevD: Sep 8 2017, 14:46


--------------------
* Beyond that, don't ask, when you don't know what to do with the answer. *
♥ home is where the heart is ♥
Go to the top of the page
 
+Quote Post
ragtag
post Sep 8 2017, 16:25
Post #3


Member


Group: Full Members
Posts: 66
Joined: 16-February 13
Member No.: 17578
Mp3tag Version: 2.54



Thank you very much for taking the time to provide the solution, DetlevD. The leading zero is simply my own preference. biggrin.gif

I created an Action using the regular expression you provided, but it did not deliver any result. I conclude that I misunderstood you on how to apply it. These were my steps:

ACTIONS > New (Renumber Tracks with Leading Zero) > Regular Expression Field: TRACK > Regular Expression: $regexp(%_filename%,'^0*(\d+)[\.\s\-]+(.+?)$','$1').

This post has been edited by ragtag: Sep 8 2017, 16:27
Go to the top of the page
 
+Quote Post
ohrenkino
post Sep 8 2017, 17:01
Post #4


Member


Group: Full Members
Posts: 8999
Joined: 9-December 09
From: Norddeutschland / Northern Germany
Member No.: 11458
Mp3tag Version: 2.84a



ZITAT(ragtag @ Sep 8 2017, 17:25) *
....
ACTIONS > New (Renumber Tracks with Leading Zero) > Regular Expression Field: TRACK > Regular Expression: $regexp(%_filename%,'^0*(\d+)[\.\s\-]+(.+?)$','$1').


The type of action should be "Format value" - the regular expression is already in the $regexp() function. So what you did, was more or less apply a regular expression twice the second one being an invalid expression though.

So try "Format value" for TRACK


--------------------
42 - wie war die Frage / what was the question / quelle était la question
Go to the top of the page
 
+Quote Post
ragtag
post Sep 8 2017, 17:09
Post #5


Member


Group: Full Members
Posts: 66
Joined: 16-February 13
Member No.: 17578
Mp3tag Version: 2.54



Thank you, Ohrenkino, I missed that.

Quickly re-tried it, but the tracks were numbered without the zero.

This post has been edited by ragtag: Sep 8 2017, 17:12
Go to the top of the page
 
+Quote Post
DetlevD
post Sep 8 2017, 17:32
Post #6


Member


Group: Full Members
Posts: 6634
Joined: 26-May 06
From: Wuppertal, Germany, Planet Earth
Member No.: 3194
Mp3tag Version: 2.84



QUOTE (ragtag @ Sep 8 2017, 17:25) *
... I created an Action using the regular expression you provided, but it did not deliver any result. ...

I want to point out, that my formatstring proposal does not "Renumber Tracks with Leading Zero".
Read again the given example.

Once you have isolated the track number from the filename, and stored this track number within the tagfield TRACK, you can create a new filename of your wish.
While doing this, you may store leading zeroes into the new filename as you like it.

Using the converter "Tag - Tag" [Alt+5], you can get a preview how a formatstring works.
Field: TEST
... or ...
Field: TRACK
Formatstring: $regexp(%_filename%,'^0*(\d+)[\.\s\-]+(.+?)$','$1')

If the formatstring works ok and delivers the track number only, then put this formatstring as an action "Format value on tagfield TRACK" into an actiongroup with a name of your wish.

Once you have the isolated track number stored within the tagfield TRACK, then you may create a new filename.
As usual you may do zero-padding the track number.

Example:
_FILENAME <== $num(%TRACK%,3)'. '%TITLE%' - '%ARTIST%

DD.20170908.1832.CEST


--------------------
* Beyond that, don't ask, when you don't know what to do with the answer. *
♥ home is where the heart is ♥
Go to the top of the page
 
+Quote Post
ragtag
post Sep 8 2017, 19:01
Post #7


Member


Group: Full Members
Posts: 66
Joined: 16-February 13
Member No.: 17578
Mp3tag Version: 2.54



Thank you DetlevD. I am unable to pay the attention due to it, straight away. I will do so by Sunday or Monday, and will report if I run into problems again.

Have a great weekend all. smile.gif
Go to the top of the page
 
+Quote Post
ragtag
post Sep 9 2017, 20:36
Post #8


Member


Group: Full Members
Posts: 66
Joined: 16-February 13
Member No.: 17578
Mp3tag Version: 2.54



DetlevD, my English is not good enough to thoroughly grasp what you are are explaining. It think I also failed to explain properly what I needed, to begin with. Could try again, please? Here goes:

I want to renumber the tracks to contain a leading zero- wherever the zero is appropriate. Each track should be numbered according to, but irrespective of, the number format of the current track number which is contained in each file name. Once this action is completed, and the new track numbers now contain the required leading zero, I will proceed to rename the file names where needed.

In conjunction with the above, I wish to combine another action with which to renumber the tracks of multi-disc albums, but is probably advisable to post that as a separate topic.

I am always very grateful for any assistance.
Go to the top of the page
 
+Quote Post
ohrenkino
post Sep 9 2017, 21:23
Post #9


Member


Group: Full Members
Posts: 8999
Joined: 9-December 09
From: Norddeutschland / Northern Germany
Member No.: 11458
Mp3tag Version: 2.84a



If you want to re-format an existing entry in TRACK to get more leading zeros, try an action of the type
Format value for TRACK
Format string: $num(%track%,2)


--------------------
42 - wie war die Frage / what was the question / quelle était la question
Go to the top of the page
 
+Quote Post
ragtag
post Sep 9 2017, 22:51
Post #10


Member


Group: Full Members
Posts: 66
Joined: 16-February 13
Member No.: 17578
Mp3tag Version: 2.54



QUOTE (ohrenkino @ Sep 9 2017, 22:23) *
If you want to re-format an existing entry in TRACK to get more leading zeros, try an action of the type
Format value for TRACK
Format string: $num(%track%,2)


Thank you, but I see a problem arising when a zeroes have to be added--or not added--to a large number of differently formatted TRACK fields, simultaneously. Some TRACK fields may already have the leading zero, some not, and then some tracks may not even be numbered at all. That is one reason for wishing to use the filename to supply the track number. The other is to ensure that the track number and the title in the filename, always corresponds i.e. that there is not a mismatch of title and track number.

This post has been edited by ragtag: Sep 9 2017, 22:52
Go to the top of the page
 
+Quote Post
DetlevD
post Sep 10 2017, 02:48
Post #11


Member


Group: Full Members
Posts: 6634
Joined: 26-May 06
From: Wuppertal, Germany, Planet Earth
Member No.: 3194
Mp3tag Version: 2.84



QUOTE (ragtag @ Sep 9 2017, 23:51) *
... I see a problem arising when a zeroes have to be added--or not added--to a large number of differently formatted TRACK fields ... Some TRACK fields may already have the leading zero, some not ... and then some tracks may not even be numbered at all. ...

If you want to remove leading zeroes from the track number you may apply the following formatstring against the tagfield TRACK:
Converter "Tag-Tag" ... or ... Action "Format value".
Field: TRACK
Formatstring: $if(%TRACK%,$num(%TRACK%,1),)

DD.20170910.0348.CEST


--------------------
* Beyond that, don't ask, when you don't know what to do with the answer. *
♥ home is where the heart is ♥
Go to the top of the page
 
+Quote Post
ragtag
post Sep 10 2017, 07:49
Post #12


Member


Group: Full Members
Posts: 66
Joined: 16-February 13
Member No.: 17578
Mp3tag Version: 2.54



QUOTE (DetlevD @ Sep 10 2017, 03:48) *
If you want to remove leading zeroes from the track number you may apply the following formatstring against the tagfield TRACK:
Converter "Tag-Tag" ... or ... Action "Format value".
Field: TRACK
Formatstring: $if(%TRACK%,$num(%TRACK%,1),)

DD.20170910.0348.CEST
...

DetlevD, but I want to add -- not subtract -- the zero to the track number in the Field: TRACK, by using the filename as the source. I am disheartened by my lack of ability to explain this any better, and I hope that it will not discourage you, or anyone else, from proposing a solution.

Ohrenkino's solution is already good to go, bar one little problem:

QUOTE
If you want to re-format an existing entry in TRACK to get more leading zeros, try an action of the type
Format value for TRACK
Format string: $num(%track%,2)
...

To me, his solution appears to be less complicated, because it neutralizes my requirement for the original filename to be used as source for the track number. I have yet to test it extensively, and the only shortcoming I have found so far is that it will not correctly apply the track number when the Field: TRACK is blank, in which case all the track numbers are converted to "00".

This post has been edited by ragtag: Sep 10 2017, 07:51
Go to the top of the page
 
+Quote Post
DetlevD
post Sep 10 2017, 09:53
Post #13


Member


Group: Full Members
Posts: 6634
Joined: 26-May 06
From: Wuppertal, Germany, Planet Earth
Member No.: 3194
Mp3tag Version: 2.84



QUOTE (ragtag @ Sep 10 2017, 08:49) *
... I want to add -- not subtract -- the zero to the track number in the Field: TRACK, by using the filename as the source.

If you want to follow the proposal from above post #2, then you will get the track number from the given filename written into the tagfield TRACK.
As a following step you may adjust the TRACK value with leading zero numbers by using function $num(), but keep in mind that there is at least one file format (MP4) in the world, which cannot store such track number format with leading zero.
If there are already track numbers in the tagfield TRACK, then you can step over getting track number from filename.

The function $num() can help to format the tag-field TRACK as you like it.
Within this thread you got already examples for all cases how to apply the function $num():
$num(%TRACK%,1) ... remove leading zeroes, gives just the number;
$num(%TRACK%,2) ... prepend the zero character to give two digit number strings: 00,01,02,03,04,05,06,07,08,09;
$num(%TRACK%,3) ... prepend the zero character to give three digit number strings: 000,001,002,...,010,011,012.

As you have pointed out, the filenames need a consistent format.
Once you have already formatted track numbers in the tagfield TRACK, then you can apply the given content from the tagfield TRACK to built a proper filename, by using the content operator %TRACK%.

Keep in mind that the tagfield TRACK does not need to be formatted with leading zeroes, because all formatting can be done within a format string 'on the fly' by applying the function $num() on the content operator %TRACK% (see above).

QUOTE (ragtag @ Sep 10 2017, 08:49) *
... I have found so far is that it will not correctly apply the track number when the Field: TRACK is blank, in which case all the track numbers are converted to "00".

You got already the hint for a fitting formatstring, e. g.: $if(%TRACK%,$num(%TRACK%,2),)

DD.20170910.1053.CEST


--------------------
* Beyond that, don't ask, when you don't know what to do with the answer. *
♥ home is where the heart is ♥
Go to the top of the page
 
+Quote Post
ragtag
post Sep 10 2017, 10:25
Post #14


Member


Group: Full Members
Posts: 66
Joined: 16-February 13
Member No.: 17578
Mp3tag Version: 2.54



Thank you DetlevD, I will concentrate and try again. You have been very patient, and helpful.

This post has been edited by ragtag: Sep 10 2017, 10:26
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 19th September 2017 - 16:10