Fixing Missing Artists and Albums in Music Library on Server

I fixed an issue with missing artists and albums that were not showing up in my music library & learn how I resolved this frustrating problem.

Last weekend I was poking around my music collection on my server and noticed a bunch of artists and albums not showing up in my library (I use Zune to listen to my music and copy it to my phone). Diving in I noticed one folder was full of M4A files… arg! Damn iTunes format… I don’t want Apple or Microsoft format, I want standard plain old MP3! Using the following PowerShell command, I found there were a ton of these types of files on my server:

Get-ChildItem "\\\RIVERCITY-NAS1\\Music" -recurse -include *.m4a

Yikes… over 800 files! OK, that’s enough to look for a way to automate this conversion process. After a bit of research, I found the freely available VLC player had the ability to convert these types of files… for free. Sweet! So after a little work, I got this PowerShell script working:

function ConvertToMp3(
    \[switch\] $inputObject,
    \[string\] $vlc = 'C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe')
    $codec = 'mp3';
    $oldFile = $_;
    $newFile = $oldFile.FullName.Replace($oldFile.Extension,
    &"$vlc" -I dummy "$oldFile" ":sout=#transcode{acodec=$codec,vcodec=dummy}:standard{access=file,mux=raw,dst=`'$newFile`'}" vlc://quit | out-null;
    # delete the original file
    Remove-Item $oldFile;
function ConvertAllToMp3(\[string\] $sourcePath) {
  Get-ChildItem "$sourcePath\\*" -recurse -include *.m4a | ConvertToMp3;
ConvertAllToMp3 '\\\RIVERCITY-NAS1\\Music';

Sweet… until I noticed all the MP3 files didn’t have any ID3 tags. So I needed to add a step. I found an old copy of the TagLib# library. that would read the tags from one file and copy them to another. So I added the following function to the script:

function DuplicateId3Tags
    param (

  # load sharp library for working with tags
    [Reflection.Assembly]::LoadFrom("C:\\Users\\andrew.RIVERCITY\\Documents\\Music Workshop\\taglib-sharp.dll")
  #load files
  $sourceM4a = [TagLib.File]::Create($sourceM4aTrack);
  $targetMp3 = [TagLib.File]::Create($targetMp3Track);

  # copy tags
  [TagLib.Tag]::Duplicate($sourceM4a.Tag, $targetMp3.Tag, $true);


And added a call to the function right before I delete the original file and voila… 100% MP3 again!

# update ID3 tags on target file
DuplicateId3Tags "$oldFile" "$newFile";
Andrew Connell
Developer & Chief Course Artisan, Voitanos LLC. | Microsoft MVP
Written by Andrew Connell

Andrew Connell is a web & cloud developer with a focus on Microsoft Azure & Microsoft 365. He’s received Microsoft’s MVP award every year since 2005 and has helped thousands of developers through the various courses he’s authored & taught. Andrew’s the founder of Voitanos and is dedicated to helping you be the best Microsoft 365 web & cloud developer. He lives with his wife & two kids in Florida.

Share & Comment