0

I'm using this module, called MPTag, in Powershell: http://powershell.com/cs/media/p/9129.aspx

It's used for editing an audio track's metadata. It works great, but I need to add leading 0's to track numbers and it's not accepting the leading zero. It just saves the integer without the leading zero.

What I'm currently using is:

$songmeta = get-mediainfo $song
$song.track = 01
$song.save()

I've also tried adding .tostring, but it still comes out without the zero. Anyone have any ideas how I can do this? I'm very new to scripting, so I can't really understand the taglib source archive that's linked to on the download page. Is there any way I can get these leading zeros in? If not, does anyone know any other metadata editing method that would work? Thanks for any help.

EDIT: work-around solution I've found is to use FFMPEG's metadata editor. It allows you to write the leading zero. More info on this wiki page.

Matthew Goode
  • 105
  • 1
  • 9
  • 1
    That library may not support what you're trying to do. If I had to guess, it uses number internally for that field, with a default `toString()` for writing. You may be able to modify [the source code](http://taglib-sharp.sourcearchive.com/) to do what you want. – Ryan Bemrose May 24 '16 at 19:46
  • 1
    The one thing I'd try is use quotes to force the data type to string and see if that helps. `$song.track = "01"` – Ryan Bemrose May 24 '16 at 19:47
  • I tried quotes, no good, unfortunately. But thanks for the advice. How exactly would I begin to edit the source code? Do I have this library downloaded on my computer? Or would I just edit the .dll of the module itself? Edit: Nevermind just noticed the .dll came with the library. I'll examine it and see if there's anything obvious I can change. – Matthew Goode May 24 '16 at 20:38
  • I've created a new question as I think I've entered a whole new world of discussion. If you know anything about editing source code, feel free to help me out! Thanks for your help though @RyanBemrose – Matthew Goode May 24 '16 at 21:42

1 Answers1

0

What I am currently using is the Split function. It may not be exactly what you are looking for, but it should be a 90% solution. I have to rip all of my cds after I lost my RAID.

Example file: 01 - Song.mp3
$files = get-childitem "your_directory" -filter *.mp3
foreach($a in $files)
{
    $b = $a.basename.Split(' - ')
    $c = '0'+$b[0]+' - '+$b[1]+$a.extension
    Rename-Item $a.Fullname -NewName $c
}
Shadow
  • 1