Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access Music File Metadata in Powershell [closed]

So over the years between getting copied from one PC/hard drive to the next, my music collection is in a bit of a mess, so I want to go through each one programmatically and update the file metadata in the below screenshot (from right click > Properties on the file):

enter image description here

Some of the files are MP3 so I know ID3 can be used there (I had tried using Get-Content to view the last 128 bytes where the ID3 tags go, but only some small bits show as readable text, assuming this is because it's a binary file and needs decoded/parsed in some specific way). About an equal number are WMA (quite an old codec version, probably 7 or 8) and some are uncompressed WAV.

So I possibly need two things:

a) a way to access and update the ID3 info for the MP3 type files b) a way to access the File Properties (at the Windows level) for WMA and WAV; if this method would also work for MP3 that'd be fantastic

Anyone got any ideas? I know this is possible in C# but that's a bit over my head right now as more used to scripting. If it needs to be done in a proper compiled program so be it but hoping there's a way to do it in shell.

like image 795
Thomas Gass Avatar asked Jul 25 '17 08:07

Thomas Gass


People also ask

How do I find the metadata of an audio file?

There are a number of programs you can use to track down missing metadata. We recommend looking at programs like Media Monkey, Audacity and JRiver which allow you to search their database for the correct info and simply drag and drop in the album artwork you're missing.

How do I get file attributes in PowerShell?

To get file attributes in PowerShell, you can use Get-ChildItem or Get-Item cmdlets. It returns the file attributes or properties available on the specified files. To get the list of all properties available, use the Get-Member cmdlet.


1 Answers

Download the tagsharp.dll from HERE.

There is a separate module which can be used to modify any of the meta data like:

get-childitem mylocal.mp3 | set-album "MyLocalAlbum"

or something like this :

$files = Get-ChildItem D:\Folder -include *.mp3 -recurse 
[System.Reflection.Assembly]::LoadFile("C:\TagLibDirectory\taglib-sharp.dll" ) 

foreach($iFile in $files) 
{ 
    $iFile.fullname    
    $mediaFile=[TagLib.File]::Create($iFile.fullname)    
    $mediaFile.Tag.Album = $iFile.Directory.Name 
    $mediaFile.Tag.AlbumArtists=$iFile.Directory.Name 
    $mediaFile.Save()   
}

Hope it helps.

like image 70
Ranadip Dutta Avatar answered Sep 21 '22 12:09

Ranadip Dutta