After several hours trying to get the UltraID3Lib working i gave up and implemented a more pragmatic solution which does the job.
I incuded the command line tool "ID3 Editor" into my Winbatch program. Here is the code i tested it with.
Best thing is that the major functions "Remove tags", "Set tags", "Insert cover art" and "Insert lyrics" are just a single command this way each.
The function "Read all tags" requires some more effort.
Thanks for your support.
;***************************************************************************
;** Mp3 ID3v2.3 and ID3v1 tag read / write / delete
;**
;** Purpose: Read / write / delete Mp3 file tags (including cover art and lyrics)
;** Inputs: mp3 file, cover art import jpg file, lyrics import txt file
;** Outputs: Updated mp3 file, tag export xml file, lyrics export txt file
;** Comment: Requires ID3 Editor package (license: $15)
;** Comment: Download ID3 Editor package here (32 and 64bit version available):
http://www.pa-software.com/downloads.php;
;** Comment: This program demonstrates straightforward functionality without error handling only
;**
;** Developer: Kay 2014.10.09
;***************************************************************************
;Set variables
;---------------------------------------------------------------------------
ProgID3Edit = "C:\Programme\Pa-software\Windows ID3 Editor\id3edcmd.exe"
FileMp3WithPath = "L:\Test\Data\Artist - Album - TrackNr - Title.mp3"
FileCoverArtImportWithPath = "L:\Test\Data\CoverArtImport.jpg"
FileLyricsImportWithPath = "L:\Test\Data\LyricsImport.txt"
FileLyricsExportWithPath = "L:\Test\Data\LyricsExport.txt"
FileXmlWithPath = "L:\Test\Data\Export.xml"
;These are all tags i need
TagArtist = "ACDC"
TagAlbumArtist = "ACDC"
TagAlbum = "HIGHWAY TO HELL"
TagSet = 1
TagNumberOfSet = 1
TagTrackNr = 1
TagTitle = "HIGHWAY TO HELL"
TagYear = 1979
TagGenre = "CLASSIC HARD ROCK"
TagBPM = ""
TagComment = "FILEID-D20030822-T22531367"
TagComposer = "ANGUS & MALCOM YOUNG"
TagPublisher = "ELEKTRA"
;Function 1: Remove existing ID3v2.3 tags (including picture and lyrics) and ID3v1 tags. Existing tags created by Mp3Gain are fortunately not touched
;---------------------------------------------------------------------------
RunShell(ProgID3Edit, `-rm1 -rm2 "%FileMp3WithPath%"`, "", @HIDDEN, @WAIT)
;;Function 2: Set tags: ID3v2.3 (and ID3v1 with built-in truncation if a tag is too long)
;;---------------------------------------------------------------------------
;RunShell(ProgID3Edit, `-ar "%TagArtist%" -or "%TagAlbumArtist%" -al "%TagAlbum%" -sn "%TagSet%" -ss "%TagNumberOfSet%" -tr "%TagTrackNr%" -ti "%TagTitle%" -yr "%TagYear%" -gn "%TagGenre%" -bm "%TagBPM%" -co "%TagComment%" -cm "%TagComposer%" -pb "%TagPublisher%" -a "%TagArtist%" -b "%TagAlbum%" -n "%TagTrackNr%" -t "%TagTitle%" -y "%TagYear%" -c "%TagComment%" "%FileMp3WithPath%"`, "", @HIDDEN, @WAIT)
;
;;Function 3: Insert cover art
;;---------------------------------------------------------------------------
;RunShell(ProgID3Edit, `-im "%FileCoverArtImportWithPath%" "%FileMp3WithPath%"`, "", @HIDDEN, @WAIT)
;
;;Function 4: Insert lyrics
;;---------------------------------------------------------------------------
;RunShell(ProgID3Edit, `-ly "%FileLyricsImportWithPath%" "%FileMp3WithPath%"`, "", @HIDDEN, @WAIT)
;Function 5: Do functions 2, 3 and 4 with a single update of the mp3 file to save time
;---------------------------------------------------------------------------
Param = `-ar "%TagArtist%" -or "%TagAlbumArtist%" -al "%TagAlbum%" -sn "%TagSet%" -ss "%TagNumberOfSet%" -tr "%TagTrackNr%" -ti "%TagTitle%" -yr "%TagYear%" -gn "%TagGenre%" -bm "%TagBPM%" -co "%TagComment%" -cm "%TagComposer%" -pb "%TagPublisher%" -a "%TagArtist%" -b "%TagAlbum%" -n "%TagTrackNr%" -t "%TagTitle%" -y "%TagYear%" -c "%TagComment%"`
If FileExist(FileCoverArtImportWithPath) == @TRUE Then Param = StrCat(Param, ` -im "%FileCoverArtImportWithPath%"`)
If FileExist(FileLyricsImportWithPath) == @TRUE Then Param = StrCat(Param, ` -ly "%FileLyricsImportWithPath%"`)
Param = StrCat(Param, ` "%FileMp3WithPath%"`)
RunShell(ProgID3Edit, Param, "", @HIDDEN, @WAIT)
;Function 6: Read all tags
;---------------------------------------------------------------------------
;Export tag info into a xml file
RunShell(ProgID3Edit, `-xml "%FileXmlWithPath%" "%FileMp3WithPath%"`, "", @HIDDEN, @WAIT)
;Parse the xml file according to
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/dotNet/System_XML+SelectNode.txtobjXml = ""
objXnList = ""
objXn = ""
ObjectClrOption("use", "System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
objXml = ObjectClrNew("System.Xml.XmlDocument")
StrXml = FileGet(FileXmlWithPath)
StrXml = StrReplace(StrXml, "</br>", @CRLF) ;the lyrics tag contains </br> (representing a line feed) without corresponding opening
which causes "objXml.LoadXml(StrXml)" to give error 1261
objXml.LoadXml(StrXml)
; TagArtist
TagArtist = ""
objXnList = objXml.SelectNodes("/tag[@version='1.0']/id3[@version='2']/value [@name='Artist']")
ForEach objXn In objXnList
objXn = ObjectClrType("System.Xml.XmlNode", objXn)
TagArtist = objXn.InnerText
Next
TagArtist = StrReplace(TagArtist, "&", "&")
; Other tags => copy and adjust the TagArtist example according to your needs
; Export lyrics into a readable txt file
TagLyrics = ""
objXnList = objXml.SelectNodes("/tag[@version='1.0']/id3[@version='2']/value [@name='Lyrics']")
ForEach objXn In objXnList
objXn = ObjectClrType("System.Xml.XmlNode", objXn)
TagLyrics = objXn.InnerText
Next
TagLyrics = StrReplace(TagLyrics, "&", "&")
FilePut(FileLyricsExportWithPath, TagLyrics)
; Export cover art is not supported (no issue for me since i store the input.jpg files separately anyway)
If objxn != "" Then ObjectClose(objXn)
If objXnList != "" Then ObjectClose(objXnList)
If objXml != "" Then ObjectClose(objXml)
Exit