Standardize Track Numbers

Discuss and share scripts and script files...
Post Reply
Posts: 321
Joined: 13 Jun 2016 04:19

Standardize Track Numbers

Post by Dustydog »

Since I posted that last, I thought I'd post this too. It's pretty straightforward, but handy. This standardizes track numbers to two digits, padded, with a dot space on the end. If there are three or four digits, it assumes a CD was present and puts it in ##-##dotspace. It cleans off old formatting from a variety of different formats, e.g. #1), 1-, etc. It's not for every track list, but it does well with most. I left in a debugging variable if you want to see previews before each change, or make changes yourself.

Another approach, if it's really messy, is just clean everything off the front that isn't a number, then renumber it all. Or another, take the metadata track number and use disc number? and track number. But this gives very consistent results, is very fast, and it works on search lists, e.g. .flac for a big CD set with indifferently standardized tracks, but with track numbers present.

Again, it's in the form I use for a multiscript.

Code: Select all

"Standardize Number: # ## ### #### ##-## #-## not beyond 99||| : Std#"
  //This standardizes numbers for most music tracks. For 3 and 4 digit numbers, it assumes the first one or two are a CD that belongs before a dash.
  //So don't use it if you really want ###dotspace padded, or whatever, i.e. past 99
  //Numbers are standardized to: (##-)?##dotspace. Zeros are added for single digits on either of the two halves of the possible dash and CD number.

  $debugPreview = ""; //or "p" if you want a preview.

  rename r, "^# > ",                                                                      "$debugPreview"; //Removes initial '#'. Just one.
  rename r, "^(\d+)[ .](\d+)([^\d\-].+) > $1$2$3",                                        "$debugPreview"; //Removes any space or dot between initial numbers. Just one.
  rename r, "^[\(\[]?((?:[\d\-]{0,4}\d)|(?:[A-Z]\d))[\)\]]?[^A-Z\d\(\[\{]*(.+) > $1. $2", "$debugPreview"; //Clean, add dot space.
  rename r, "^(\d)(\. .+) > 0$1$2",                                                       "$debugPreview"; //# to 0#; ## OK.
  rename r, "^(\d)(\d\d\. .+) > 0$1-$2",                                                  "$debugPreview"; //### to 0#-##
  rename r, "^(\d\d)(\d\d\. .+) > $1-$2",                                                 "$debugPreview"; //#### to ##-##
  rename r, "^(\d)-(\d\d) > 0$1-$2",                                                      "$debugPreview"; //#-## to ##-##
  rename r, "^(\d)-(\d\. .+) > 0$1-0$2",                                                  "$debugPreview"; //#-# to 0#-0#

Posts: 321
Joined: 13 Jun 2016 04:19

Re: Standardize Track Numbers

Post by Dustydog »

The reason I posted these, rather than more elaborate things that I've done, is that I find XY the most useful with a big handful of micro-utilities. In fact, you could think of just using the interface that way (mostly - some things it does are pretty elaborate). So even though these are hardly showcase scripts, they do something quickly using essentially a single XY feature (rename >> in the first and regex renames in the second script), and are a part of how I muddle through going through my (mostly) audio files in these cases. These two scripts get used often, and they save me time. They didn't take long to write, and they made me glad I knew a little XY scripting when I wrote them (and how to use regular expressions on a beginning level in the second as well).

I'll pretty up and share my html parser sometime that I use in some big scripts, because I think if I clean it up, somebody might use it. For certain things, using the html feature is the only way to display things with enough complexity. These, I mostly shared to show how something quite simple can be handy, and I was glad I could write them back when I did. So go ahead and learn scripting, share your little utilities, and not just your masterworks. (Though I'm very grateful for some of the masterworks shared from people like highend.) The bigger scripts that I use are mostly useful to just myself, but each one has saved me enough time to make up for the effort it took to write.

And don't forget how easily XY incorporates other utilities. I have 79 custom file associations listed, and most of them are active and used - useful one liners. For example, I like to see things in MediaInfo. So, my standard double click on a media file opens MediaInfo, then centers and sizes it with AHK. Really simple stuff, but I use it a lot (in spite of the great information features from Don, which I use too). Some invoke ImageMagick, which is a lot quicker to use for little things from XY than any other image editor.

I wish people would post their little things too. Things that aren't too elegant maybe, but that they find useful. So, that's why these are up.

If, say, highend thinks they're pointless, go ahead and zap them. I won't be offended. I know they're not terribly polished and only mildly useful for most people. I'd just like to see more posts from different people's little utility bags.

Posts: 10571
Joined: 06 Feb 2011 00:33

Re: Standardize Track Numbers

Post by highend »

I don't think they are pointless^^

What I don't like is the way how it is executed. Nobody (ok, at least me) wants to preview x (the number of patterns) rename steps and renaming things x number of times isn't really a good thing (especially on SSDs).

So something like this would suit (me) a lot more (only one preview and only a single rename):
Standardize track numbers.xys
(1.96 KiB) Downloaded 15 times
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

Post Reply