Strip total disc number from discnumber field

This seems like it should be a simple thing to do, but I searched for about 15 minutes on the forum and didn't see this mentioned in any of the posts, so -- here we go... :unsure:

I have quite a number of MP3's which have the disc number formatted as x/x (that is, 1/4, 2/4, 3/4, 4/4 -- instead of simply 1, 2, 3, 4). What I want to do is remove the "/x" (the total disc number listed in the field), so that it only displays that particular disc number.

Anyone know of an action that will take care of this?

I also wouldn't mind something that would do something similar in the track number field (i.e., strip the total tracks from that field, leaving only each individual track number behind).

Like I said, I figure this must be a simple thing, but I'm not very knowledgeable in how to accomplish the task. :flushed:

Thanks in advance for any assistance! :slight_smile:

The simplest way may be to use the $fmtNum() function. I use it on the track number field.

Action type: Format value
Format string: $fmtNum(%discnumber%)

Action type: Format value
Field: TRACK
Format string: $fmtNum(%track%)

Whoo-hoo! Works like a charm. (I have no idea how or why it works, but I don't care! :smiley: )

Thanks so much, JJ. :sunglasses:

You can also use the function $num() to do the same.
For example ... $num(%discnumber%,1)

This works for all strings with a leading number and following any non-digit character ... e. g.
$num('123abc456',1) ==> 123
$num('123abc456',2) ==> 123
$num('123abc456',3) ==> 123
$num('123abc456',4) ==> 0123
$num('123abc456',5) ==> 00123


Another way to skin a cat!!

Name of action group: &Remove#Total No. Of &Disks

Action type: Replace with regular expression
Regular expression: ^(\d+)/\d+
Replace matches with: $1

[ ] case-sensitive comparison
1 Like

See, I knew this would be a walk in the park for the resident geniuses here. However, I have a followup which, I'd guess, may be slightly more complex. :wink:

After I posted that original query, a related question popped into my head, and as long as it's sort of germane, I figured I may as well posit that one in this thread, as well...

In my initial wandering through the forum looking for an answer to my issue above, I came across a few people mentioning an extended tag called either TOTALDISCS or DISCTOTAL. So I wondered if there was a way to 1) strip that total disc number from the DISCNUMBER field, and at the same time 2) write that same number to this extended tag/field (total # of discs). Because I can see where it'd be handy to keep that info (on the total number of discs), but not have to "dirty up" the DISCNUMBER tag with extraneous info.

(And then, of course -- not being sensible to leave well enough alone -- I was curious as to whether there was a similar extended tag in regards to tracks, i.e., TOTALTRACKS or TRACKTOTAL -- and if so, how a similar feat might be accomplished.)

Apologies if this is considered "hijacking my own thread". It's just that I'm always about finding shortcuts and making things more efficient, even if I don't exactly know how to do it myself. :smiley:

Muchas gracias!

The actual field names used for total tracks and total discs are somewhat application dependent. There really isn't an accepted standard, so it's best to find out what your favorite music program uses. You could even write the values to multiple fields, although that can sometimes be difficult to maintain.

There are a number of ways to separate the values. Assuming that all of your discnumber fields have that same x/y structure that you showed in your first post, I would do it like this:

Action #1
Action type: Guess values
Source format: %discnumber%
Guessing pattern: %discnumber%/%totaldiscs%

Action #2
Action type: Format value
Format string: $fmtNum(%discnumber%)

Action #3
Action type: Format value
Format string: $fmtNum(%totaldiscs%)

Actions #2 and #3 aren't strictly necessary, but I would include them just in case, to clean up any unwanted characters such as spaces or leading zeroes that might have been in the original.

Repeat the above for TRACK and TOTALTRACKS (or TRACKTOTAL).

The original post of how to change disc number 1/4, 2/4, 3/4, 4/4 to 1,2,3,4

As a Basic, TurboBasic, & Pascal programmer, I revert back to the basics, and used:

Format String: $left(%discnumber%,1)

Which changes the DISCNUMBER field, to be whatever is in the leftmost digit, of the current DISCNUMBER field. If the field is empty, it stays empty.

This only works up to 9/9 to 9. At 10/10 something else would be needed.

Or use:
Format String: $num(%discnumber%,1)

This skips anything non-numeral, so everything foloowing the slash.

1 Like