1

I'm ultimately aiming to get a hashtable of the path and ISRC of all the MP3 files in my music library for use in organising my library. Right now, I am having trouble getting the ISRC information out of the files. I have checked it is there using other software, but I particularly need to read it using powershell.

I've tried using a few Get-FileMetaData functions, but I think I was looking in the wrong place with that attempt.

In place of reading it the 'proper' way, I attempted to just read the file as plain text with Get-Content and manipulate the string to isolate the ISRC, which I can find when viewing the file in Notepad. The difficulty I ran into is managing the way the text is encoded (if that is the right word). There are whitespace characters inbetween the characters when viewed in notepad, which don't show up in PowerShell but still seem to count toward string length.

I would try to provide some code, but all I've had are dead ends, and I think the issue is in my understanding of what I'm working with. If I've skipped over any important information, please let me know. Tagged with unicode on a vague hunch that the string manipulation involves unicode.

So, how can I properly read the id3v2 tags using powershell (By properly I mean without bodgy string manipulation), or how can I interpret the raw file contents using powershell, i.e. deal with the special characters and whitespaces.

Thanks very much.

Raw content example: (Where the piece of interest is the text following 'TSRC')

ID3 >1TCON ) ÿþS i n g e r & S o n g w r i t r TRCK 1 TPOS 1 TIT2 ÿþv a l e n t i n e TPE1
ÿþD a f n a TXXX ÿþA R T I S T S ÿþD a f n a TALB ÿþv a l e n t i n e TPE2
ÿþD a f n a TLEN 151000TPUB # ÿþM a r g a l i t R e c o r d s TSRC ÿþQ Z 8 L D 1 9 8 6 2 3 3 TXXX - ÿþB A R C O D E ÿþ1 9 3 6 6 4 6 1 1 6 0 3 TYER 2019TDAT 0702APIC ‰ image/jpeg cover ÿØÿà JFIF H H ÿÛ C

2 Answers2

0

Get-Content has a parameter for -encoding.

If you can work out the encoding of those files, just put it in that parameter.

It's also worth checking your powershell version. I believe this behaviour changed between 5 and 6.

OwlsSleeping
  • 1,487
  • 2
  • 11
  • 19
  • The most common encodings for MP3 files are UTF-8, UTF-16 and ISO-8859-1. The 'ISRC' frame should contain the International Standard Recording Code (ISRC) with 12 characters. – PeterCo Jun 26 '22 at 21:44
  • Hi, thanks for the suggestion, I'd never heard of the -Encoding parameter. Having now fiddled around with it, I don't think any of the options powershell provides are making neat sense of the content. Regarding @PeterCo comment, of those three options only UTF-8 is provided by Get-Content. – AlexRussell Jun 27 '22 at 07:59
  • Why does this look like UTF-32? It clearly is UTF-16BE (one ASCII character, one NULL). – AmigoJack Aug 06 '22 at 19:14
0

Maybe this Access Music File Metadata in Powershell answer - using taglib.dll can help you too.

PeterCo
  • 910
  • 2
  • 20
  • 36