DEV Community

uyriq
uyriq

Posted on • Updated on

Powershell to fix incorrect encoding of MP3 ID3 tags

This PowerShell script corrects the encoding of ID3 tags in MP3 files. It is specifically designed for the case of a problem where tags encoded in WINDOWS-1251 have been saved to files as WINDOWS-1252 text, and so programs incorrectly output grainy characters (like this one"îñòðîâ") because they read the text as a Western European encoding. So the task is to save tags in modern UTF-8 encoding. TagLibSharp.dll does all the work of reading tags from the file, so to make the script work you need to place this library in the script execution directory.

Prerequisites

Before running this script, make sure you have the following:

  • PowerShell 5.1 or higher.
  • TagLibSharp.dll: This is required to work with MP3 tags. You can obtain `TagLibSharp.dll by either:
    • By downloading it from NuGet.
    • Or by compiling the source code available on GitHub.

How to use

  1. Get TagLibSharp.dll: To download or compile TagLibSharp.dll, see above.
  2. Locate TagLibSharp.dll in the same directory as the script: The script expects TagLibSharp.dll to be in the same directory from which the script is run.
  3. Prepare MP3 files: Make sure that all MP3 files you want to fix are placed in the same directory. The script will process all .mp3 files in the directory from which it is run.
  4. Run the script:.
    • Open PowerShell and navigate to the directory containing the script and TagLibSharp.dll.
    • Run the script by typing .\convertIDv3tags.ps1 and pressing Enter. The script will process each MP3 file in the catalog, correcting the ID3 tag encoding as described.

Notes

  • Backup your files:Before running the script, it is recommended that you back up your MP3 files to prevent unintentional data loss.
  • Script Restrictions: The script is specifically restricted to working with MP3 files. Changing the -Filter *.mp3 parameter to work with other file formats may not produce the desired results, although in general TagLibSharp.dll supports even video.

**NotaBene: if u wish experiment more with TagLibSharp dive in with

Top comments (0)