PowerShell : Renaming And Sorting All My Music Files

We have a large collection of MP3s and FLACs and most of the time they all work great.  I’ve spent quite a bit of time getting their metadata correct so the various players we have all play them in the correct order as they use their Disc and Track number metadata to sort them.

However my wife’s and I’s cars both can read music from SD cards.  This is great as they’re a lot faster to process than phone libraries over Bluetooth but the downside is that the only sorting they do is via the filename.  This means every album plays it’s tracks in alphabetical order.

Ideally to fix this what I want is a script to rename each music file according to it’s Disc Number, Track Number and Title metadata.  The script I wrote to do exactly that follows, with some explanations after. Continue reading “PowerShell : Renaming And Sorting All My Music Files”