Q. How can I use Windows PowerShell to update a file's media tags?

A. When I recently reviewed my music library, I found I had a lot of music videos, which I'd used the naming format <artist>-<song>.wmv. I also found that the files' media tags were blank, so if I tried to view the videos with Windows Media Player (WMP), I would just see blank names. I wanted to automate the media tag population in PowerShell through the filename but couldn't work out how to update the title and performer media tags.

Then I ran across a tag library at developer.novell.com/wiki/index.php/TagLib_Sharp that allows access to various languages' media tags. I downloaded the tag library and saved it to my computer. Then I wrote the code

cd "D:\Multimedia\Film\Music Videos"
foreach ($f in dir)
$mediafile = \[TagLib.File\]::Create(“D:\Multimedia\Film\Music Videos\” + $f.ToString())
$splitName = $f.Name.Split(”-.")
write-host $splitname\[0\] $splitname\[1\]
$mediafile.Tag.Title = $splitname\[0\] + "-" + $splitname\[1\]
$mediafile.Tag.Performers = $splitname\[0\]

to parse my music-video folder files and populate the tags accordingly. Obviously, you can change how the script works and what it populates, but this script will give you a good start. You need to modify the script's first line (at minimum) to show where you saved the taglib DLL.

Once I executed the script, all my media files' title and performer tags were populated.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.