Home > PowerShell > Change the track name of music files using PowerShell

Change the track name of music files using PowerShell

I went to my friend room last week to see cricket match. He got a new mobile phone and trying to copy all his favorite songs into it. After copying a few he realized that, file name that appearing his laptop and display name in phone are not same for songs he is copying. He disappointed and figureout that he has o change the title of each song by going to properties of each mp3 file. As I just sitting beside to him, he asked me if I can automate anything there to speed up the process. He has lot of MP3 files in such manner and thought of helping him with my favorite powershell scripting.

I authored a small script, which reads files of given extension type and changes the title of them to file name. So that music players shows the same name when playing…

[powershell]
$files = Get-ChildItem -Filter *.mp3 -Path c:MyMusic -Recurse
$wmp = New-Object -ComObject wmplayer.ocx

foreach ($file in $files) {
$filename = $file.FullName
$fileshortname = $file.Name.Split(".")[0]
$metadata = $wmp.newMedia($filename)
if ($metadata.name -ne $fileshortname) {
Write-Host "Setting metadata"
$metadata.name = $fileshortname

}
}
[/powershell]

No related content found.

  1. Ramesh
    April 25, 2010 at 9:41 pm | #1

    it works…thank you

  2. Altair
    February 23, 2012 at 3:06 am | #2

    so how does it work (sorry, new to powershell) should i copy it to my phone or ??

  1. No trackbacks yet.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>