Looking for id3v2 tag mp3 write script

Discuss and share scripts and script files...
Post Reply
Ysl
Posts: 128
Joined: 03 Jan 2007 22:22

Looking for id3v2 tag mp3 write script

Post by Ysl » 22 Mar 2020 17:34

Hi

Can someone help me with a script which will allow me to write the name of a mp3 file to the id3v2 'artist' tag of the same file ?

This is already build in but for id3v1 only....

Thanks for your help

highend
Posts: 8678
Joined: 06 Feb 2011 00:33

Re: Looking for id3v2 tag mp3 write script

Post by highend » 22 Mar 2020 18:54

For ID3v2.3?

Get https://github.com/squell/id3/releases/ ... 3-080w.zip

Adapt the path and use:

Code: Select all

    $tool = "D:\Tools\@Command Line Tools\id3\id3.exe";
    end (exists($tool) != 1), "$tool was NOT found, aborted!";

    foreach($file, <get SelectedItemsPathNames |>, , "e") {
        if (exists($file) != 1) { continue; }
        $name = gpc($file, "base");
        status "Processing: " . $name, , "progress";
        $result = runret("""$tool"" -M -a ""$name"" ""$file""", , 65001, 2);
        end ($result), "An error occurred at file: " . $name . ", terminated...";
    }
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

Ysl
Posts: 128
Joined: 03 Jan 2007 22:22

Re: Looking for id3v2 tag mp3 write script

Post by Ysl » 22 Mar 2020 20:46

Thank you for your help :)

I tried this but it wrote only ID3V1 and the text (file name) is limited to 30 characters..

highend
Posts: 8678
Joined: 06 Feb 2011 00:33

Re: Looking for id3v2 tag mp3 write script

Post by highend » 22 Mar 2020 20:52

In my tests it wrote (into existing) id3v2.3 tags.

Try -2 and read the docs.

I didn't test for any length limitation. If it doesn't work try to find a different command line id3 tagger...

E.g. you could build a golang binary with this library: https://github.com/bogem/id3v2
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

highend
Posts: 8678
Joined: 06 Feb 2011 00:33

Re: Looking for id3v2 tag mp3 write script

Post by highend » 22 Mar 2020 23:09

This is a binary (64-bit), that uses the library from above.
It can write ID3v2.3 or ID3v2.4 tags: Album, Artist, Comment, Genre, Title, Year

Code: Select all

Usage:  id3tagger.exe <tag(s)|option(s)> "<mp3 file 1|text file with file(s)>" ["<mp3 file x>"]

        Possible tag(s)   : -album, -artist, -comment, -genre, -title, -year
        Possible option(s): -id3type

        Example: id3tagger.exe -id3type 3 -artist "Adele" -title "Someone like you" "D:\unknown song.mp3"
-id3type can either be 3 (for ID3v2.3) or 4 (for ID3v2.4). 4 is the default.

Multiple files can be tagged at once (with the same tags ofc!) so you could e.g. tag 20 files in one call with the same set of supplied tags.
You can either supply one or multiple mp3 files OR only one text file containing full paths to mp3 files.
This text file must be saved in either UTF-8 or UTF-8 with BOM!

So you could also process 1000 files if you execute something like this (if the .txt file contains 1000 existing mp3 files...):
id3tagger.exe -id3type 4 -genre "Pop" "D:\file with lots of .mp3 files.txt"

Btw, this does need about 4,5 seconds here (modifying 1000 files)...

Use with care! This is not heavily tested but works on my sample files...
id3tagger_v0.2.zip
(1.45 MiB) Downloaded 3 times
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

highend
Posts: 8678
Joined: 06 Feb 2011 00:33

Re: Looking for id3v2 tag mp3 write script

Post by highend » 24 Mar 2020 09:44

A small update to v0.2, it now supports writing comments as well so at least the standard attributes are supported:
Album, Artist, Comment, Genre, Title, Year
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

Ysl
Posts: 128
Joined: 03 Jan 2007 22:22

Re: Looking for id3v2 tag mp3 write script

Post by Ysl » 24 Mar 2020 10:43

Thanks again

I added the -2 but don't know where to put it !
$result = runret("""$tool"" -M -a ""$name"" ""$file""", , 65001, 2) -2;
It works (write into id3v1 & v2 without lenght limitation) BUT after complete I have this message (not a script error message) :

"An error occurred at file xx. terminated..."

highend
Posts: 8678
Joined: 06 Feb 2011 00:33

Re: Looking for id3v2 tag mp3 write script

Post by highend » 24 Mar 2020 11:42

It's an option for the $tool...
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

Ysl
Posts: 128
Joined: 03 Jan 2007 22:22

Re: Looking for id3v2 tag mp3 write script

Post by Ysl » 24 Mar 2020 12:21

Sorry, my question is how to get rid of the error message so I can tag a batch of file and don't have to click OK each time

I presume that I have not placed at the right position the -2 you advised me to try

highend
Posts: 8678
Joined: 06 Feb 2011 00:33

Re: Looking for id3v2 tag mp3 write script

Post by highend » 24 Mar 2020 12:33

$result = runret("""$tool"" -2 -M -a ""$name"" ""$file""", , 65001, 2);
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

Ysl
Posts: 128
Joined: 03 Jan 2007 22:22

Re: Looking for id3v2 tag mp3 write script

Post by Ysl » 24 Mar 2020 14:40

Perfect !

THANK YOU VERY MUCH :tup: :D

Post Reply