TheSaint Posted April 18, 2011 Posted April 18, 2011 (edited) @joeyb1275 - just a quick mention in passing, as I haven't yet had a chance to check it out properly, but a bunch of MP3's in a folder I was checking out, kept causing my program to crash when parsing the tags. One thing I noticed about all the Track Title tags, were that they all started with a time and then text (i.e. 12:30 Last Train). I'm guessing at this point, that the illegal filename character of ':' is at fault somehow. If I remember correctly, it was a Roger Waters album ... not that that is important I suppose.I've now started looking into this, and the error message is an AutoIt one about memory allocation, which I've tracked to a FileRead one at this point, which I recall may be related to the temporary fix I implemented earlier and which you queried me over at for which I now answer 'YES' obviously. I can send you one of the mp3's that give the error if you like or link to it in a PM?EDITThe crash happens after a FileRead for TRCK, and when attempting to do a FileRead for a $FrameID called ÿTLE, which is an illegal or corrupt tag ID (or maybe not enough bytes are being read and a buffer overflow is happening or somesuch that is beyond my level of full understanding), and supposed to be TTLE I guess. Related to unicode perhaps or the fact that the tag name is not one of the accepted and so it can't return anything for it and must, so it crashes ... or I just don't know what I'm talking about?Hopefully this is not caused by a virus infected mp3, which is taking advantage of a stack overflow, that hasn't been programmed to prevent?NOTE - Roger Waters - The Pros And Cons Of HitchhikingNOTE 2 - Obviously my temporary fix is not a real fix, it just stops my program from crashing, after which I can rewrite all tags with my program and then the issue is gone. I can also open with MP3Tag (which doesn't complain) and save the tags and then open them without issue with my program ... so whatever is causing the issue, is not a standard one I suspect, though it may be legal and need a bugfix for. Edited April 18, 2011 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
TheSaint Posted April 22, 2011 Posted April 22, 2011 @joeyb1275 - I've also re-discovered that you still haven't completed some of the ID3 version 1 elements (some parts are still missing, which you no doubt forgot to get back to), which I had implemented myself in my earlier update ... not sure if I documented all of those for you (track title, etc).Also of note, was that I missed seeing until later, that MP3Tag was reporting the problem files from the above posts, as having BAD ID3 tags ... it reported them in the column for ID3 tag type, but didn't give me a prompt, etc ... so they remained unnoticed for a while. Still, your UDF should be able to cope and return an error, without causing AutoIt to crash my program.On a more positive note, I've been using my programs that utilize your UDF a lot lately, and the changes you made etc, work great, so once again you have my thanks! Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
BrewManNH Posted April 26, 2011 Posted April 26, 2011 I've been looking through the code for this UDF and I've been noticing that there's a lot of code in there that serves no purpose, variables declared and then never used, items read into a variable but this information isn't used in the function it's in. I only noticed this because I was running AU3Check on a media player I'm developing and I had tried to use some of the functions from this UDF and it was throwing errors up all over the place. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
TheSaint Posted April 29, 2011 Posted April 29, 2011 I've been looking through the code for this UDF and I've been noticing that there's a lot of code in there that serves no purpose, variables declared and then never used, items read into a variable but this information isn't used in the function it's in. I only noticed this because I was running AU3Check on a media player I'm developing and I had tried to use some of the functions from this UDF and it was throwing errors up all over the place. I've have noticed things as well, but have just presumed that it is an unfinished udf, as several things at least, are incomplete ... but some are wrong too, possibly due to testing not complete ... or things forgotten to be restored after. The reason some ID3v1.x tags are not being returned for instance, is that Line 130 For $i = 3 To $ID3BufferArray[0] should be For $i = 1 To $ID3BufferArray[0] which would mean that Title and Artist are also returned in the final array. There are also missing pieces & errors elsewhere to Version being returned for ID3v1.x and ID3V2.x The key one for ID3v1.x is the tag (key) 'Version1' which by my testing, should be just 'Version' to return the value (around Line 927). I also added what appeared to be the missing Case statement as well (around Line 1166), which I entered as - Case "Version" ;ID3v1 ; Case for Version was missing, so added by TheSaint $bTagFieldFound = True $sFrameString = $aFrameData[2]I made my own work-a-round for ID3V2.x which had no obvious return method that I could discern, so I just created a variable ($id3vers) from existing calls ($ID3v2Version etc) and returned it instead of the 1. Hopefuly joeyb1275 will eventually get around to fixing these and the other issues etc I've mentioned, like he did the Unicode. If he doesn't get back to it within a reasonable amount of time, then I'll post what I've fixed (i.e. my complete version of his UDF), but it must be remembered that I have not studied his code to any degree of depth, so much of what I've done is just a quick fix. You can pretty much see the changes I've added, by looking at the version I posted previously, which I've used as the basis for most of my current fixes ... with a little tweaking ... all except the code for the $id3vers variable mentioned above, which is new. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
flashlab Posted May 6, 2011 Posted May 6, 2011 I've have noticed things as well, but have just presumed that it is an unfinished udf, as several things at least, are incomplete ... but some are wrong too, possibly due to testing not complete ... or things forgotten to be restored after. The reason some ID3v1.x tags are not being returned for instance, is that Line 130 For $i = 3 To $ID3BufferArray[0] should be For $i = 1 To $ID3BufferArray[0] which would mean that Title and Artist are also returned in the final array. There are also missing pieces & errors elsewhere to Version being returned for ID3v1.x and ID3V2.x The key one for ID3v1.x is the tag (key) 'Version1' which by my testing, should be just 'Version' to return the value (around Line 927). I also added what appeared to be the missing Case statement as well (around Line 1166), which I entered as - I made my own work-a-round for ID3V2.x which had no obvious return method that I could discern, so I just created a variable ($id3vers) from existing calls ($ID3v2Version etc) and returned it instead of the 1. Hopefuly joeyb1275 will eventually get around to fixing these and the other issues etc I've mentioned, like he did the Unicode. If he doesn't get back to it within a reasonable amount of time, then I'll post what I've fixed (i.e. my complete version of his UDF), but it must be remembered that I have not studied his code to any degree of depth, so much of what I've done is just a quick fix. You can pretty much see the changes I've added, by looking at the version I posted previously, which I've used as the basis for most of my current fixes ... with a little tweaking ... all except the code for the $id3vers variable mentioned above, which is new. I've look though all your post, it seems you've spent lots of time on this UDF. So do I. And all the trouble you've met also puzzled me. It's really a complex project, what I can do is just hoping crash .etc not occured this one is what I used currently, wish to help some what → ID3_flashlab.au3
TheSaint Posted May 6, 2011 Posted May 6, 2011 I've look though all your post, it seems you've spent lots of time on this UDF. So do I. And all the trouble you've met also puzzled me. It's really a complex project, what I can do is just hoping crash .etc not occured this one is what I used currently, wish to help some what → ID3_flashlab.au3 No worries, when I get a chance I'll have a look at it. I'm actually quite surprised more people aren't as interested as you or I ... or maybe they just aren't commenting ... or don't want to share ... or possibly prefer using some 3rd party DLL, etc? Once the major issue is fixed, then I may share my creations that use the UDF, but I still have some issues with tags not being updated sometimes ... which puzzles me, and I find that more often than not, it involves deleting the whole tag or tags to fix it ... silly little things, like adding the YEAR tag to the existing instead of replacing it, and this can occur with other tags like TRACK number. Sometimes the Artwork when updated, won't show in some other programs either, which is only fixed when I use MP3Tag or a foobar2000 option to save, etc. Possibly this might be something to do with APE tags or the incorrect number of bytes not being read/written, etc? I also had an issue where the Variable Bitrate header was not reporting correctly after a Save or Fix, but I don't think this has been happening since the latest update by joeyb1275? Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
BrewManNH Posted May 6, 2011 Posted May 6, 2011 I've been using the BASS function and DLL to read the tag information because it's a lot faster. But unfortunately there's no functionality to write tags with it, so I've been trying to get this one to work for me. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
lesolutionneur Posted January 31, 2012 Posted January 31, 2012 (edited) I've found a bug in your awesome UDF:$hFile = FileOpen($Filename,16) ;read force binary FileRead($hFile,$OldTagSize) ;read past Old Tag FileWrite($hTagFile,FileRead($hFile,FileGetSize($Filename) - 128 - $OldTagSize)) ;Write the mp3 dataIt actually writes the file even the file wasn't open successfully:If the file is not open, it overwrite it with only the MP3Tags.For fixing it, you can:$hFile = FileOpen($Filename,16) ;read force binary If $hfile = -1 then for $i = 0 to $i = 5 ;try 6 times before saying that there is a problem opening the file sleep(100 + $i * 50) ;each try, wait a longer time $hFile = FileOpen($Filename,16) if $hFile <> -1 then ExitLoop Next EndIf If $hFile <> -1 then FileRead($hFile,$OldTagSize) ;read past Old Tag FileWrite($hTagFile,FileRead($hFile,FileGetSize($Filename) - 128 - $OldTagSize)) ;Write the mp3 data ETC... Else return 0 EndIfI hope this work and that I didn't any error in my code (if it's the problem, you can add me in the credits to thank me)GreetingsEDIt: same in the functions _ReadID3v2 and _ReadID3v1 Edited January 31, 2012 by lesolutionneur
Flok3r Posted February 22, 2012 Posted February 22, 2012 (edited) Hi, I simply want to remove all tag information with this script and it wont work at all. I tried each version of the udf posted here, but the script stops everytime at the _ID3ReadTag when scanning a mp3, which is already "tag-less". It runs fine, if every file in the array has any tags, though they arent removed sometimes. Im using the latest version of Autoit on a Win7 x86 computer expandcollapse popup#include <array.au3> #include <GUIConstantsEx.au3> #include <ID3.au3> #RequireAdmin #NoTrayIcon #AutoIt3Wrapper_Res_FileVersion=1 #AutoIt3Wrapper_Res_Description=Removes all ID-Tag Info #AutoIt3Wrapper_Compression=4 Dim $tagtypes[25] = [24, _ "TIT2", _ "COMM", _ "TRCK", _ "TYER", _ "TLEN", _ "ZPAD", _ "TSSE", _ "TPUB", _ "UFID", _ "TPE2", _ "WCOM", _ "WXXX", _ "WOAR", _ "TCON", _ "Title", _ "Artist", _ "Album", _ "Track", _ "Year", _ "Genre", _ "Comment", _ "APIC", _ "TALB", _ "TPE1"] $addtofinallist = False Dim $finallist[1] = [0] GUICreate("TagRemover", 200, 130) $lastmod = GUICtrlCreateLabel("Last modified: ", 10, 10, 180, 50) $currentfile = GUICtrlCreateLabel("Enumerating .mp3's.. ", 10, 70, 180, 50) GUISetState() $list = FileListToArrayEx(@ScriptDir, '*.mp3', 1) ;files only AdlibRegister("checkexit", 30) If IsArray($list) Then For $i = 1 to $list[0] GUICtrlSetData($currentfile, "Current File: " & @CRLF & $list[$i]) _ID3ReadTag($list[$i], 0, -1);ERROR"! For $j = 1 To $tagtypes[0] If _ID3GetTagField($tagtypes[$j]) <> "" Then _ID3SetTagField($tagtypes[$j], "") $addtofinallist = True EndIf Next If $addtofinallist = True Then GUICtrlSetData($lastmod, "Last modified: " & @CRLF & $list[$i]) $addtofinallist = False _ArrayAdd($finallist, $list[$i]) _ID3WriteTag($list[$i]) EndIf Next _ID3DeleteFiles(); delete albumart GUIDelete() $finallist[0] = UBound($finallist) - 1 _ArrayDisplay($finallist) Exit Else GUIDelete() MsgBox(0, "Error", "No mp3s found.") EndIf Func checkexit() If GUIGetMsg() = $GUI_EVENT_CLOSE Then GUIDelete() $finallist[0] = UBound($finallist) - 1 _ArrayDisplay($finallist) Exit EndIf EndFunc ;==>checkexit Func FileListToArrayEx($s_path, $s_mask = "*.*", $i_flag = 0, $s_exclude = -1, $f_recurse = True, $f_full_path = True) If FileExists($s_path) = 0 Then Return SetError(1, 1, 0) ; Strip trailing backslash, and add one after to make sure there's only one $s_path = StringRegExpReplace($s_path, "[/]+z", "") & "" ; Set all defaults If $s_mask = -1 Or $s_mask = Default Then $s_mask = "*.*" If $i_flag = -1 Or $i_flag = Default Then $i_flag = 0 If $s_exclude = -1 Or $s_exclude = Default Then $s_exclude = "" ; Look for bad chars If StringRegExp($s_mask, "[/:><|]") Or StringRegExp($s_exclude, "[/:><|]") Then Return SetError(2, 2, 0) EndIf ; Strip leading spaces between semi colon delimiter $s_mask = StringRegExpReplace($s_mask, "s*;s*", ";") If $s_exclude Then $s_exclude = StringRegExpReplace($s_exclude, "s*;s*", ";") ; Confirm mask has something in it If StringStripWS($s_mask, 8) = "" Then Return SetError(2, 2, 0) If $i_flag < 0 Or $i_flag > 2 Then Return SetError(3, 3, 0) ; Validate and create path + mask params Local $a_split = StringSplit($s_mask, ";"), $s_hold_split = "" For $i = 1 To $a_split[0] If StringStripWS($a_split[$i], 8) = "" Then ContinueLoop If StringRegExp($a_split[$i], "^..*?..*?z") Then $a_split[$i] &= "*" & $a_split[$i] EndIf $s_hold_split &= '"' & $s_path & $a_split[$i] & '" ' Next $s_hold_split = StringTrimRight($s_hold_split, 1) If $s_hold_split = "" Then $s_hold_split = '"' & $s_path & '*.*"' Local $i_pid, $s_stdout, $s_hold_out, $s_dir_file_only = "", $s_recurse = "/s " If $i_flag = 1 Then $s_dir_file_only = ":-d" If $i_flag = 2 Then $s_dir_file_only = ":d" If Not $f_recurse Then $s_recurse = "" Local $i_buffer, $t_input, $t_output, $s_hold_binary $i_pid = Run(@ComSpec & " /u /c dir /b " & _ $s_recurse & "/a" & $s_dir_file_only & " " & _ $s_hold_split, "", @SW_HIDE, 4 + 2) ; Collect data from std i/o stream While 1 $s_stdout = StdoutRead($i_pid, False, True) If @error Then ExitLoop $i_buffer = BinaryLen($s_stdout) $t_input = DllStructCreate("byte[" & $i_buffer & "]") $t_output = DllStructCreate("char[" & $i_buffer & "]") DllStructSetData($t_input, 1, $s_stdout) DllCall("kernel32.dll", "int", "WideCharToMultiByte", _ "int", 0, "int", 0, "ptr", DllStructGetPtr($t_input), _ "int", $i_buffer / 2, "ptr", DllStructGetPtr($t_output), _ "int", $i_buffer, "int", 0, "int", 0) $s_hold_out &= StringRegExpReplace(DllStructGetData($t_output, 1), "(?i)(?:A|v)(?:(0+v+)|(0+))|(v*0+z)", "") $t_input = 0 $t_output = 0 WEnd ; Replace any extending verticle spaces from the end of the string $s_hold_out = StringRegExpReplace($s_hold_out, "v+z", "") If Not $s_hold_out Then Return SetError(5, 5, 0) ; Parse data and find matches based on flags Local $a_fsplit = StringSplit(StringStripCR($s_hold_out), @LF), $s_hold_ret $s_hold_out = "" If $s_exclude Then $s_exclude = StringReplace(StringReplace($s_exclude, "*", ".*?"), ";", "|") Local $i_path_len = BinaryLen($s_path) For $i = 1 To $a_fsplit[0] If $s_exclude And StringRegExp(StringRegExpReplace( _ $a_fsplit[$i], "(.*?[/]+)*(.*?z)", "2"), "(?i)" & $s_exclude) Then ContinueLoop If StringRegExp($a_fsplit[$i], "^w:[/]+") = 0 Then $a_fsplit[$i] = $s_path & $a_fsplit[$i] If $f_full_path Then $s_hold_ret &= $a_fsplit[$i] & Chr(1) Else $s_hold_ret &= StringTrimLeft($a_fsplit[$i], $i_path_len) & Chr(1) EndIf Next $s_hold_ret = StringTrimRight($s_hold_ret, 1) If $s_hold_ret = "" Then Return SetError(6, 6, 0) Return StringSplit($s_hold_ret, Chr(1)) EndFunc Id be happy if anyone could try that script, perhaps correct it and advise me. Since Im still new to Autoit, any suggestions with regard to the structure in general are welcome too! PS: of course the filelisttoarrayex func doesnt matter EDIT: Thats strange.. it works, if i dont use the _ID3GetTagField, but while testing with debug msgboxes the script never ran further than _ID3ReadTag. But Id prefer not to rewrite the tag info of all files, how can i get this done then? Edited February 22, 2012 by Flok3r
TheSaint Posted February 24, 2012 Posted February 24, 2012 @Flok3r - Just saw your post, so haven't tested anything ... and may not get around to it ... so don't wait for me. However, I'll point out a few factors I've discovered about this udf - 1) It's incomplete. 2) Very wrong in places. 3) Can't cope with Ape tags when they also exist. 4) Can't cope with ID3v2.4 or later. 5) Doesn't deal properly with Extended tags. Over time I've addressed some of these issues to a degree, though my results are not completely satisfactory, and so I have my program also use other programs like Mp3Tag, Tagscanner, foobar2000, etc ... if only to check things or remove Ape, Extended & ID3v2.4 tags. If I get time soon, I may upload my program, which uses this UDF and a File properties UDF. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
flashlab Posted March 7, 2012 Posted March 7, 2012 Hi, I simply want to remove all tag information with this script and it wont work at all. I tried each version of the udf posted here, but the script stops everytime at the _ID3ReadTag when scanning a mp3, which is already "tag-less". It runs fine, if every file in the array has any tags, though they arent removed sometimes. Im using the latest version of Autoit on a Win7 x86 computer expandcollapse popup#include <array.au3> #include <GUIConstantsEx.au3> #include <ID3.au3> #RequireAdmin #NoTrayIcon #AutoIt3Wrapper_Res_FileVersion=1 #AutoIt3Wrapper_Res_Description=Removes all ID-Tag Info #AutoIt3Wrapper_Compression=4 Dim $tagtypes[25] = [24, _ "TIT2", _ "COMM", _ "TRCK", _ "TYER", _ "TLEN", _ "ZPAD", _ "TSSE", _ "TPUB", _ "UFID", _ "TPE2", _ "WCOM", _ "WXXX", _ "WOAR", _ "TCON", _ "Title", _ "Artist", _ "Album", _ "Track", _ "Year", _ "Genre", _ "Comment", _ "APIC", _ "TALB", _ "TPE1"] $addtofinallist = False Dim $finallist[1] = [0] GUICreate("TagRemover", 200, 130) $lastmod = GUICtrlCreateLabel("Last modified: ", 10, 10, 180, 50) $currentfile = GUICtrlCreateLabel("Enumerating .mp3's.. ", 10, 70, 180, 50) GUISetState() $list = FileListToArrayEx(@ScriptDir, '*.mp3', 1) ;files only AdlibRegister("checkexit", 30) If IsArray($list) Then For $i = 1 to $list[0] GUICtrlSetData($currentfile, "Current File: " & @CRLF & $list[$i]) _ID3ReadTag($list[$i], 0, -1);ERROR"! For $j = 1 To $tagtypes[0] If _ID3GetTagField($tagtypes[$j]) <> "" Then _ID3SetTagField($tagtypes[$j], "") $addtofinallist = True EndIf Next If $addtofinallist = True Then GUICtrlSetData($lastmod, "Last modified: " & @CRLF & $list[$i]) $addtofinallist = False _ArrayAdd($finallist, $list[$i]) _ID3WriteTag($list[$i]) EndIf Next _ID3DeleteFiles(); delete albumart GUIDelete() $finallist[0] = UBound($finallist) - 1 _ArrayDisplay($finallist) Exit Else GUIDelete() MsgBox(0, "Error", "No mp3s found.") EndIf Func checkexit() If GUIGetMsg() = $GUI_EVENT_CLOSE Then GUIDelete() $finallist[0] = UBound($finallist) - 1 _ArrayDisplay($finallist) Exit EndIf EndFunc ;==>checkexit Func FileListToArrayEx($s_path, $s_mask = "*.*", $i_flag = 0, $s_exclude = -1, $f_recurse = True, $f_full_path = True) If FileExists($s_path) = 0 Then Return SetError(1, 1, 0) ; Strip trailing backslash, and add one after to make sure there's only one $s_path = StringRegExpReplace($s_path, "[/]+z", "") & "" ; Set all defaults If $s_mask = -1 Or $s_mask = Default Then $s_mask = "*.*" If $i_flag = -1 Or $i_flag = Default Then $i_flag = 0 If $s_exclude = -1 Or $s_exclude = Default Then $s_exclude = "" ; Look for bad chars If StringRegExp($s_mask, "[/:><|]") Or StringRegExp($s_exclude, "[/:><|]") Then Return SetError(2, 2, 0) EndIf ; Strip leading spaces between semi colon delimiter $s_mask = StringRegExpReplace($s_mask, "s*;s*", ";") If $s_exclude Then $s_exclude = StringRegExpReplace($s_exclude, "s*;s*", ";") ; Confirm mask has something in it If StringStripWS($s_mask, 8) = "" Then Return SetError(2, 2, 0) If $i_flag < 0 Or $i_flag > 2 Then Return SetError(3, 3, 0) ; Validate and create path + mask params Local $a_split = StringSplit($s_mask, ";"), $s_hold_split = "" For $i = 1 To $a_split[0] If StringStripWS($a_split[$i], 8) = "" Then ContinueLoop If StringRegExp($a_split[$i], "^..*?..*?z") Then $a_split[$i] &= "*" & $a_split[$i] EndIf $s_hold_split &= '"' & $s_path & $a_split[$i] & '" ' Next $s_hold_split = StringTrimRight($s_hold_split, 1) If $s_hold_split = "" Then $s_hold_split = '"' & $s_path & '*.*"' Local $i_pid, $s_stdout, $s_hold_out, $s_dir_file_only = "", $s_recurse = "/s " If $i_flag = 1 Then $s_dir_file_only = ":-d" If $i_flag = 2 Then $s_dir_file_only = ":d" If Not $f_recurse Then $s_recurse = "" Local $i_buffer, $t_input, $t_output, $s_hold_binary $i_pid = Run(@ComSpec & " /u /c dir /b " & _ $s_recurse & "/a" & $s_dir_file_only & " " & _ $s_hold_split, "", @SW_HIDE, 4 + 2) ; Collect data from std i/o stream While 1 $s_stdout = StdoutRead($i_pid, False, True) If @error Then ExitLoop $i_buffer = BinaryLen($s_stdout) $t_input = DllStructCreate("byte[" & $i_buffer & "]") $t_output = DllStructCreate("char[" & $i_buffer & "]") DllStructSetData($t_input, 1, $s_stdout) DllCall("kernel32.dll", "int", "WideCharToMultiByte", _ "int", 0, "int", 0, "ptr", DllStructGetPtr($t_input), _ "int", $i_buffer / 2, "ptr", DllStructGetPtr($t_output), _ "int", $i_buffer, "int", 0, "int", 0) $s_hold_out &= StringRegExpReplace(DllStructGetData($t_output, 1), "(?i)(?:A|v)(?:(0+v+)|(0+))|(v*0+z)", "") $t_input = 0 $t_output = 0 WEnd ; Replace any extending verticle spaces from the end of the string $s_hold_out = StringRegExpReplace($s_hold_out, "v+z", "") If Not $s_hold_out Then Return SetError(5, 5, 0) ; Parse data and find matches based on flags Local $a_fsplit = StringSplit(StringStripCR($s_hold_out), @LF), $s_hold_ret $s_hold_out = "" If $s_exclude Then $s_exclude = StringReplace(StringReplace($s_exclude, "*", ".*?"), ";", "|") Local $i_path_len = BinaryLen($s_path) For $i = 1 To $a_fsplit[0] If $s_exclude And StringRegExp(StringRegExpReplace( _ $a_fsplit[$i], "(.*?[/]+)*(.*?z)", "2"), "(?i)" & $s_exclude) Then ContinueLoop If StringRegExp($a_fsplit[$i], "^w:[/]+") = 0 Then $a_fsplit[$i] = $s_path & $a_fsplit[$i] If $f_full_path Then $s_hold_ret &= $a_fsplit[$i] & Chr(1) Else $s_hold_ret &= StringTrimLeft($a_fsplit[$i], $i_path_len) & Chr(1) EndIf Next $s_hold_ret = StringTrimRight($s_hold_ret, 1) If $s_hold_ret = "" Then Return SetError(6, 6, 0) Return StringSplit($s_hold_ret, Chr(1)) EndFunc Id be happy if anyone could try that script, perhaps correct it and advise me. Since Im still new to Autoit, any suggestions with regard to the structure in general are welcome too! PS: of course the filelisttoarrayex func doesnt matter EDIT: Thats strange.. it works, if i dont use the _ID3GetTagField, but while testing with debug msgboxes the script never ran further than _ID3ReadTag. But Id prefer not to rewrite the tag info of all files, how can i get this done then? Hi!Flok3r Have you tried my modified version? It work for me to remove ID1 and ID2.2/2.3 tags though _ID3WriteTag($file_dir, 1) the author has designed the function, but didn't finish it. you can use text compare tool to check the difference. hope you like it~~
flashlab Posted March 7, 2012 Posted March 7, 2012 @Flok3r - Just saw your post, so haven't tested anything ... and may not get around to it ... so don't wait for me.However, I'll point out a few factors I've discovered about this udf -1) It's incomplete.2) Very wrong in places.3) Can't cope with Ape tags when they also exist.4) Can't cope with ID3v2.4 or later.5) Doesn't deal properly with Extended tags.Over time I've addressed some of these issues to a degree, though my results are not completely satisfactory, and so I have my program also use other programs like Mp3Tag, Tagscanner, foobar2000, etc ... if only to check things or remove Ape, Extended & ID3v2.4 tags.If I get time soon, I may upload my program, which uses this UDF and a File properties UDF.Humm... the udf works fine in my project. I have test it on hundreds of mp3 files. Since most mp3 files have Id3 2.3 or lower, it apply to common use. The author seems stop complete it, we can make it better
maxthailand Posted March 11, 2012 Posted March 11, 2012 (edited) I could not Write Tag File Mp3 is UTF-16. Edited March 11, 2012 by maxthailand
joeyb1275 Posted March 23, 2012 Author Posted March 23, 2012 @Flok3r - Just saw your post, so haven't tested anything ... and may not get around to it ... so don't wait for me.However, I'll point out a few factors I've discovered about this udf -1) It's incomplete.2) Very wrong in places.3) Can't cope with Ape tags when they also exist.4) Can't cope with ID3v2.4 or later.5) Doesn't deal properly with Extended tags.Over time I've addressed some of these issues to a degree, though my results are not completely satisfactory, and so I have my program also use other programs like Mp3Tag, Tagscanner, foobar2000, etc ... if only to check things or remove Ape, Extended & ID3v2.4 tags.If I get time soon, I may upload my program, which uses this UDF and a File properties UDF.Hi all! Sorry I've been away for awhile, too long I know. I did not know this UDF was getting that much use. I would like to make this UDF better, but I could use everyone's help. It sounds like you all put these functions though the ringer. That's awesome! Please share code fixes you have with me and I will apply them. Let me know what features or new functions you would like to see in a new version. I am looking to get this working to read (and write) ID3v2.4 tags.Thanks for your help!joeyb1275
TheSaint Posted March 23, 2012 Posted March 23, 2012 Good to hear from you again joeyb1275 ... thought we'd lost you.Most of what I've done is just stop-gap quick fixes, but it may be a good place for you to start, so here it is.ID3.au3I think I've commented all the changes - just look for TheSaint to find them.Looking forward to your improvements.I'd also like to find some code that would indicate when Ape tags were present, plus allow removal of them only. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
joeyb1275 Posted April 29, 2012 Author Posted April 29, 2012 @Flok3r - Just saw your post, so haven't tested anything ... and may not get around to it ... so don't wait for me. However, I'll point out a few factors I've discovered about this udf - 1) It's incomplete. 2) Very wrong in places. 3) Can't cope with Ape tags when they also exist. 4) Can't cope with ID3v2.4 or later. 5) Doesn't deal properly with Extended tags. Over time I've addressed some of these issues to a degree, though my results are not completely satisfactory, and so I have my program also use other programs like Mp3Tag, Tagscanner, foobar2000, etc ... if only to check things or remove Ape, Extended & ID3v2.4 tags. If I get time soon, I may upload my program, which uses this UDF and a File properties UDF. I was able to add reading and writing of ID3v2.4 and reading and removal of APEv2 tags. I am trying to add reading of ID3v1.1 Extended tags but I would like to find an application that writes these tags. I am doing a lot of testing on my code before I post it so I would like to test it with other programs that write these tags. I followed the format outlined by wikipedia for the extended tags [TAG+] http://en.wikipedia.org/wiki/ID3 Does anyone know of a free application that will write the TAG+ tags?
TheSaint Posted April 30, 2012 Posted April 30, 2012 I was able to add reading and writing of ID3v2.4 and reading and removal of APEv2 tags. I am trying to add reading of ID3v1.1 Extended tags but I would like to find an application that writes these tags. I am doing a lot of testing on my code before I post it so I would like to test it with other programs that write these tags. I followed the format outlined by wikipedia for the extended tags [TAG+] http://en.wikipedia.org/wiki/ID3 Does anyone know of a free application that will write the TAG+ tags? Good stuff! I wasn't aware that Extended Tags were supported by ID3v1.1. Is this a different type of extended tags? I'll check the Wikipedia link. I know the MP3Tag program reads, displays & writes Extended Tags, as that's what I use to check them and occasionally remove them, though my own program/script prompts to or auto removes all if any found. While some see Extended Tags as useful obviously, I just see them as extra baggage and always remove them, so my only interest in any ID3v1.1 version, would be to make sure they don't exist. Too often I've seen the clash between 'ALBUMARTIST' and 'ALBUM ARTIST' ... we only need one, the original. I've seen it happen for YEAR too, by using DATE, etc. All silly and counter-productive, as I'm not prepared to deal with clashes when it comes to what is displayed in some programs/hardware. Whenever I have extra information to impart, it rightly goes in the COMMENT field. But then I don't bother with Tags/Fields outside of the 8 basic ones. My program will leave LYRICS and COMPOSER, etc alone if that is wished, but it doesn't cater for them otherwise. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
TheSaint Posted April 30, 2012 Posted April 30, 2012 @joeyb1275 - According to my interpretation, the Extended Tag thing for ID3v1.1, is just to increase the length of text in the ARTIST, ALBUM & TITLE fields, plus allow entries in the GENRE field that aren't standard. Something I knew, but hadn't associated with the term Extended, as later versions of Extended are actually a new field. Off the top of my head, I wouldn't think there was an issue - perhaps other than checking for more than 30 characters in the above fields and non-standard GENRE text. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
joeyb1275 Posted April 30, 2012 Author Posted April 30, 2012 (edited) Good stuff!I wasn't aware that Extended Tags were supported by ID3v1.1. Is this a different type of extended tags? I'll check the Wikipedia link.I know the MP3Tag program reads, displays & writes Extended Tags, as that's what I use to check them and occasionally remove them, though my own program/script prompts to or auto removes all if any found.While some see Extended Tags as useful obviously, I just see them as extra baggage and always remove them, so my only interest in any ID3v1.1 version, would be to make sure they don't exist. Too often I've seen the clash between 'ALBUMARTIST' and 'ALBUM ARTIST' ... we only need one, the original. I've seen it happen for YEAR too, by using DATE, etc. All silly and counter-productive, as I'm not prepared to deal with clashes when it comes to what is displayed in some programs/hardware. Whenever I have extra information to impart, it rightly goes in the COMMENT field. But then I don't bother with Tags/Fields outside of the 8 basic ones. My program will leave LYRICS and COMPOSER, etc alone if that is wished, but it doesn't cater for them otherwise.So from what I was able to find, the Extended Tags you are talking about are only interpreted data fields generated by MP3Tag. Here is a link to show you what I found, http://help.mp3tag.de/main_tags.htmlIt looks like you can modify the mapping as well inside of MP3Tag, http://help.mp3tag.de/main_mapping.htmlSo the way I understand these extended tags is they are only generated inside of MP3Tag when a tag is read. If the file has multiple tag types from other programs MP3Tag tries to organize and categorize them into an MP3Tag fields such as 'ALBUMARTIST' or 'ARTIST'.So it looks like MP3Tag can read WMA tags, tags from iTunes, WMP10, and Winamp which are different from ID3v2, I guess? I know I have seen iTunes edit the ID3v2 tags and I know that Winamp can edit ID3v1, ID3v2 and APEv2 tags. I have also found some WM/ tags embedded in the PRIV fields of the ID3v2 tag. I think for now I only want to keep this UDF compatible with ID3v1, ID3v2 and APEv2 tags.So I don't think I can read these Extended Tags since they are only specific to MP3Tag. But there will be a function to remove tag fields from the ID3v2 tag so that you should be able to clean up some of the tag fields these other programs add. Let me know if you find anything more on these Extended Tags. Edited April 30, 2012 by joeyb1275
TheSaint Posted April 30, 2012 Posted April 30, 2012 So from what I was able to find, the Extended Tags you are talking about are only interpreted data fields generated by MP3Tag. Here is a link to show you what I found, http://help.mp3tag.de/main_tags.htmlIt looks like you can modify the mapping as well inside of MP3Tag, http://help.mp3tag.de/main_mapping.htmlSo the way I understand these extended tags is they are only generated inside of MP3Tag when a tag is read. If the file has multiple tag types from other programs MP3Tag tries to organize and categorize them into an MP3Tag fields such as 'ALBUMARTIST' or 'ARTIST'.So it looks like MP3Tag can read WMA tags, tags from iTunes, WMP10, and Winamp which are different from ID3v2, I guess? I know I have seen iTunes edit the ID3v2 tags and I know that Winamp can edit ID3v1, ID3v2 and APEv2 tags. I have also found some WM/ tags embedded in the PRIV fields of the ID3v2 tag. I think for now I only want to keep this UDF compatible with ID3v1, ID3v2 and APEv2 tags.So I don't think I can read these Extended Tags since they are only specific to MP3Tag. But there will be a function to remove tag fields from the ID3v2 tag so that you should be able to clean up some of the tag fields these other programs add. Let me know if you find anything more on these Extended Tags.I wasn't aware that Extended Tags was a Mp3Tag thing ... are you sure? Isn't it part of the ID3 v2.x standard, and Mp3Tag is just utilizing that, just like any other program can do, and some others no doubt do?Off the top of my head, I recall that your code already deals with the Extended Tag set, just not individual elements if I remember rightly???I may have modified your code ... can't remember??I'm able to detect if any Extended Tags are present anyway, and remove them holus bolus. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now