PowerShell:从MP3读取ID3V2,特别是ISRC

发布于 2025-02-10 16:32:48 字数 933 浏览 2 评论 0原文

最终,我的目标是获取音乐库中所有MP3文件的路径和ISRC,以用于组织我的库。现在,我很难从文件中获取ISRC信息。我已经检查了使用其他软件,但我特别需要使用PowerShell阅读它。

我已经尝试使用一些GET-FILEMETADATA功能,但是我认为我尝试了错误的位置。

根据“正确”的方式,我试图将文件读为纯文本,并用gen-content读取并操纵字符串以隔离ISRC,在记事本中查看文件时,我可以找到它。我遇到的困难是管理文本编码的方式(如果是正确的话)。在Notepad中查看字符之间存在着空格字符,这些字符在powershell中不显示,但似乎仍然符合字符串长度。

我会尝试提供一些代码,但我所拥有的只是死胡同,我认为问题在于我对与之合作的工作的理解。如果我跳过任何重要信息,请告诉我。字符串操作涉及Unicode的模糊直觉上标记为Unicode。

因此,如何使用PowerShell正确读取ID3V2标签(通过正确地说,我的意思是没有Bodgy String操纵),或者如何使用PowerShell来解释原始文件内容,即处理特殊字符和Whitespaces。

非常感谢。

原始内容示例:(其中感兴趣的是“ tsrc'的文本”)

id3> 1tcon)ÿSINGER& s ongwritr trck 1 tpos 1 tit2 Alentine tpe1
= d afna txxx•a rtists = d afna talb = a alentine tpe2
d afna tlen 151000TPub#ÿMArgalit r ecords tsrc ^ q z 8 ld 1 9 8 6 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 6 6 4 6 4 6 6 4 6 1 6 1 6 1 6 0 3 Tyer 2019tdat 0702ap 0702apapic/jpeg Cover/Jpeg Covel C.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦明 2025-02-17 16:32:48

也许这个
访问powershell中的访问音乐文件元数据
答案 - 使用taglib.dll也可以帮助您。

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

谁的新欢旧爱 2025-02-17 16:32:48

get -content具有用于编码的参数。

如果您可以计算出这些文件的编码,只需将其放入该参数。

还值得检查您的PowerShell版本。我相信这种行为在5到6之间发生了变化。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文