Search This Blog

Monday, May 9, 2011

PowerShell Script to update metadata of MP3 files

Recently I have downloaded over 100 mp3 narrations on Pastimes and Activities of Supreme Personality of Godhead. However these mp3 files have a generic filename i.e. canto_chapter_index name. Now when load it my iPhone i would see the names as title and there is no why to tell which no. describes which pastime. So i googled for a while and yes got few tips and created following PS script. The script reads csv file with corresponding title and based on actual name match found it updates the title of the file, also writes Artist and Album metadata. For this script you need .netframework library called TagLib.

$TagLib = "D:\Temp\taglib-sharp-\Libraries\taglib-sharp.dll"

[System.Reflection.Assembly]::LoadFile($TagLib) | Out-Null

$KrsnaBook = import-csv C:\Users\user\Downloads\KrsnaBook.csv

cd C:\Users\user\Downloads\Krsna

foreach($fileName in Dir)
Foreach($Name in $KrsnaBook)

if($fileName.Name -eq $Name.Name)

Write-Host $Name.Title
$Media = [TagLib.File]::Create("C:\Users\user\Downloads\Krsna\" + $fileName.Name.ToString())
$Media.Tag.Title = $Name.Title
$Media.Tag.Artists = "Srila Prabhupada"
$Media.Tag.Album = "Krsna Book"


So now you can also use the the above ps code to update titles based on the filename.



  1. Can you give me the example of the contents in the file C:\Users\user\Downloads\KrsnaBook.csv.


    1. It's basically two column file one with the name of the file and one with the meta tags which I wanted. I will look up the file and then try to upload.