WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Sound and Media

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

MP3 Tools for FileMenu.txt

Keywords: 	  MP3 Tools FileMenu

; Right Click MP3 Tools v1.0.12
; Written by Mobius Jun.10.2001
; mobiustrip@mail.ru
;
; A couple small changes.
;
; Made the name formatting take place in one 
; easy dialog instead of 4 questions. 
;  
; Added a few Drop()'s to the name formatting
; so that the text to be added at the begining
; and ending of the filename isn't repeated. 
;
; Made the M3U maker a dialog instead of a 
; question.
;
; Usage\Features: 
; M3U Maker 		<-- Just insert the name for the .m3u file.
; Name Formatter 	<-- You'll be asked to insert a string to be replaced, and then 
;                           which string to be used as a replacement. After these 2 questions
;                           you'll be asked for a string to be added to the begining of the
;                           filename, and then for a string to be added to the end of the 
;                           filename, before the extension. Removes underscores and %20 by defaut.
;                           Leave all options blank to only remove underscores and %20.
; ID3 Tagger		<-- Checks to see if a tag already exists. If so you are asked whether
;                           you want to delete the existing tag or view the existing tag. 
;                           After viewing the existing tag you have the option to erase the
;                           existing tags and write new ones or exit. If you do not check the 
;                           box next to title the filenames will be used with no extension.
;                          
;                           Neither Genre or Track# are supported.
;
;                           (The process control is a little funky because there was originally the 
;                           option to write either or both id3v1 and id3v2 tags. This capability 
;                           will be added soon. Do not use BinaryPokeStr() to write tags. It will 
;                           DELETE audio data! It's only 128 bytes with id3v1, but if a song moves 
;                           between tracks you might notice a missing gap.)
;
;                           My filename for this script is: FileMenu for MP3 Files.mnw
;                           Insert this line into Filemenu.ini in your winbatch system directory:
;                           mp3=FileMenu for MP3 Files.mnw
;
;                           I've been using this for a few weeks now and I can't live without it. I 
;                           looked forever to find a program that would allow me to do these operations
;                           very easily and quickly. Each one had a different problem and left alot to 
;                           be desired. For you, this script may leave something to be desired, but 
;                           hopefully it will have no problems 
;
; Begin Script
M3U Maker
 M3U
        a=FileItemize("*.mp3")
        a=ItemSort(a,@tab)
        a=strreplace(a,@TAB,@CRLF)

	MobiusM3UFormat=`WWWDLGED,5.0`

	MobiusM3UCaption=`M3U Maker`
	MobiusM3UX=208
	MobiusM3UY=126
	MobiusM3UWidth=147
	MobiusM3UHeight=43
	MobiusM3UNumControls=4

	MobiusM3U01=`2,2,94,DEFAULT,STATICTEXT,DEFAULT,"Enter a filename below (with no .m3u)"`
	MobiusM3U02=`6,28,36,DEFAULT,PUSHBUTTON,DEFAULT,"Make M3U",1`
	MobiusM3U03=`104,28,36,DEFAULT,PUSHBUTTON,DEFAULT,"Cancel",0`
	MobiusM3U04=`2,14,142,DEFAULT,EDITBOX,b,""`


        ButtonPushed=Dialog("MobiusM3U")

		

        c=fileopen("%b%.m3u", "WRITE")
        filewrite(c, a)
		  fileclose(c)

	Exit

Name Formatter
 Format
        thisdir=DirGet()

        MobiusNamerFormat=`WWWDLGED,5.0`

        MobiusNamerCaption=`Name Formatter         (Leave blank for none)`
        MobiusNamerX=208
        MobiusNamerY=128
        MobiusNamerWidth=159
        MobiusNamerHeight=77
        MobiusNamerNumControls=10

        MobiusNamer01=`20,8,30,DEFAULT,STATICTEXT,DEFAULT,"Replace:"`
        MobiusNamer02=`8,22,36,DEFAULT,STATICTEXT,DEFAULT,"Replacement:"`
        MobiusNamer03=`2,36,40,DEFAULT,STATICTEXT,DEFAULT,"Add to Begining:"`
        MobiusNamer04=`6,50,36,DEFAULT,STATICTEXT,DEFAULT,"Add to Ending:"`
        MobiusNamer05=`42,6,114,DEFAULT,EDITBOX,dln,""`
        MobiusNamer06=`42,20,114,DEFAULT,EDITBOX,rln,""`
        MobiusNamer07=`42,34,114,DEFAULT,EDITBOX,fln,""`
        MobiusNamer08=`42,48,114,DEFAULT,EDITBOX,bln,""`
        MobiusNamer09=`10,62,38,DEFAULT,PUSHBUTTON,DEFAULT,"Format",1`
        MobiusNamer10=`104,62,40,DEFAULT,PUSHBUTTON,DEFAULT,"Cancel",0`


        ButtonPushed=Dialog("MobiusNamer")



        AddExtender("wsrch32I.dll")
        handle=srchInit(thisdir,"*.mp3","","",16)

        while 1

           formatfile=srchNext(handle)
           If formatfile == "" Then Break

           last=StrLen(formatfile)
           start=StrScan(formatfile, "\", last, @backscan)
           filename=StrSub(formatfile, (start + 1), 1000)
           filename=StrReplace(filename, dln, rln)
           filename=StrReplace(filename, "_", " ")
           filename=StrReplace(filename, "%%20", " ")

           FileRename(formatfile, filename)

        endwhile
        srchFree(handle)

        handle=srchInit(thisdir,"*.mp3","","",16)

        timedelay(2)
        Drop(formatfile, filename)
        while 1

           formatfile=srchNext(handle)
           If formatfile == "" Then Break

           last=StrLen(formatfile)
           start=StrScan(formatfile, "\", last, @backscan)
           filename=StrSub(formatfile, (start + 1), 1000)
           filename=StrReplace(filename, ".mp3", "")

           FileRename(formatfile, "%fln%%filename%%bln%.mp3")
        Drop(formatfile, filename)

        endwhile
        Exit

ID3 Tagger
 Tag
        AddExtender("wsrch32I.dll")
        thisdir=Dirget()
        handle=srchInit(thisdir,"*.mp3","","",16)
        mp3=srchNext(handle)

        size=FileSize(mp3)

        tag=binaryalloc(3)
        binaryreadex(tag,0,mp3,size-128,3)
        id3=binarypeekstr(tag,0,3)
        binaryfree(tag)

        If id3 == "TAG" 
          delyn=AskYesNo("ID3 Tagger: Delete Old Tag?", "An ID3v1 tag already exists. To delete the old tag choose 'Yes'. To view the old tag choose 'No'.")
          If delyn == @yes then GoTo deltag
          If delyn == @no then GoTo vwtag
        EndIf
        
        GoTo bgntag
  
        :deltag 
        srchFree(handle)
        handle=srchInit(thisdir,"*.mp3","","",16)

        deltag=binaryalloc(128)
        BinaryEODSet(deltag, 128)
         
        While 1

           filea=srchNext(handle)
           If filea == "" Then Break

        BinaryWriteEx(deltag, 0, filea, (size-128), 128)

        EndWhile
 
        BinaryFree(deltag)
        srchFree(handle)

        GoTo bgntag

        :vwtag
        srchFree(handle)
        handle=srchInit(thisdir,"*.mp3","","",16)
        mp3=srchNext(handle)

        oldtag=binaryalloc(125)
        BinaryReadEx(oldtag, 0, mp3, size-125, 125)
        otitle=BinaryPeekStr(oldtag, 0, 30)
        oartist=BinaryPeekStr(oldtag, 30, 30)
        oalbum=BinaryPeekStr(oldtag, 60, 30)
        oyear=BinaryPeekStr(oldtag, 90, 4)
        ocomment=BinaryPeekStr(oldtag, 94, 30)
        BinaryFree(oldtag)

        MobiusTagFormat=`WWWDLGED,5.0`

        MobiusTagCaption=`Existing ID3v1 Info`
        MobiusTagX=202
        MobiusTagY=168
        MobiusTagWidth=130
        MobiusTagHeight=87
        MobiusTagNumControls=12

        MobiusTag01=`14,72,50,DEFAULT,PUSHBUTTON,DEFAULT,"Erase and Tag",1`
        MobiusTag02=`70,72,50,DEFAULT,PUSHBUTTON,DEFAULT,"Cancel",0`
        MobiusTag03=`30,4,96,DEFAULT,STATICTEXT,DEFAULT,"%otitle%"`
        MobiusTag04=`30,18,96,DEFAULT,STATICTEXT,DEFAULT,"%oartist%"`
        MobiusTag05=`30,32,96,DEFAULT,STATICTEXT,DEFAULT,"%oalbum%"`
        MobiusTag06=`30,46,36,DEFAULT,STATICTEXT,DEFAULT,"%oyear%"`
        MobiusTag07=`30,60,96,DEFAULT,STATICTEXT,DEFAULT,"%ocomment%"`
        MobiusTag08=`14,4,10,DEFAULT,STATICTEXT,DEFAULT,"Title"`
        MobiusTag09=`8,18,16,DEFAULT,STATICTEXT,DEFAULT,"Author"`
        MobiusTag10=`10,32,16,DEFAULT,STATICTEXT,DEFAULT,"Album"`
        MobiusTag11=`10,46,14,DEFAULT,STATICTEXT,DEFAULT,"Year"`
        MobiusTag12=`2,60,22,DEFAULT,STATICTEXT,DEFAULT,"Comment"`

        ButtonPushed=Dialog("MobiusTag")
        ctag=1
        GoTo deltag


        :bgntag

        MobiusTagFormat=`WWWDLGED,5.0`

        MobiusTagCaption=`ID3 Tagger`
        MobiusTagX=202
        MobiusTagY=168
        MobiusTagWidth=130
        MobiusTagHeight=87
        MobiusTagNumControls=15

        MobiusTag01=`14,72,50,DEFAULT,PUSHBUTTON,DEFAULT,"Write Tag",1`
        MobiusTag02=`70,72,50,DEFAULT,PUSHBUTTON,DEFAULT,"Cancel",0`
        MobiusTag03=`26,2,96,DEFAULT,EDITBOX,title,""`
        MobiusTag04=`26,16,96,DEFAULT,EDITBOX,artist,""`
        MobiusTag05=`26,30,96,DEFAULT,EDITBOX,album,""`
        MobiusTag06=`26,44,36,DEFAULT,EDITBOX,year,""`
        MobiusTag07=`80,44,42,DEFAULT,EDITBOX,genre,""`
        MobiusTag08=`26,58,96,DEFAULT,EDITBOX,comment,""`
        MobiusTag09=`14,4,10,DEFAULT,STATICTEXT,DEFAULT,"Title"`
        MobiusTag10=`8,18,16,DEFAULT,STATICTEXT,DEFAULT,"Author"`
        MobiusTag11=`10,32,16,DEFAULT,STATICTEXT,DEFAULT,"Album"`
        MobiusTag12=`64,46,16,DEFAULT,STATICTEXT,DEFAULT,"Genre"`
        MobiusTag13=`10,46,14,DEFAULT,STATICTEXT,DEFAULT,"Year"`
        MobiusTag14=`2,60,22,DEFAULT,STATICTEXT,DEFAULT,"Comment"`
        MobiusTag15=`3,2,7,DEFAULT,CHECKBOX,titlechk,"",1`

        ButtonPushed=Dialog("MobiusTag")
        AddExtender("wsrch32I.dll")

        thisdir=Dirget()
        sysdir=DirHome()

        GoSub id3v1


        GoSub tag

        BinaryFree(tag1)
        Exit

        :tag
        handle=srchInit(thisdir,"*.mp3","","",16)
  
        tr=1  
        while 1
   
        If tr == 1 Then tr="01"
        If tr == 2 Then tr="02"
        If tr == 3 Then tr="03"
        If tr == 4 Then tr="04"
        If tr == 5 Then tr="05"
        If tr == 6 Then tr="06"
        If tr == 7 Then tr="07"
        If tr == 8 Then tr="08"
        If tr == 9 Then tr="09"

           tag=srchNext(handle)
           If tag == "" Then Break
        
        If titlechk == 0 Then GoSub ntid31
        If titlechk == 1 Then FileAppend("id3v1.tag", tag)

        endwhile

        srchFree(handle)
        Return

        :id3v1
        rep="TAGQtitleQQartistQQalbumQQyearQQcommentQQgenreQ"
        ClipPut(rep)

        tag1=BinaryAlloc(500)
        BinaryClipGet(tag1, 1)
        BinaryReplace(tag1, "QartistQ", StrFix(artist, "", 30), @false)
        BinaryReplace(tag1, "QalbumQ", StrFix(album, "", 30), @false)
        BinaryReplace(tag1, "QyearQ", StrFix(year, "", 4), @false)
        BinaryReplace(tag1, "QcommentQ", StrFix(comment, "", 30), @false)
        BinaryReplace(tag1, "QgenreQ", StrFix("ÿ", "", 1), @false)
        If titlechk == 1 Then BinaryReplace(tag1, "QtitleQ", StrFix(title, "", 30), @false)
        If titlechk == 1 Then BinaryWrite(tag1, "id3v1.tag")
        Return

           :ntid31
           cnt=BinaryEODGet(tag1)
           wrtag=BinaryAlloc(50000)
           BinaryCopy(wrtag, 0, tag1, 0, cnt)

           last=StrLen(tag)
           start=StrScan(tag, "\", last, @backscan)
           filename=StrSub(tag, (start + 1), 1000)
           filename=StrReplace(filename, ".mp3", "")
           title=StrReplace(filename, "_", " ")

           BinaryReplace(wrtag, "QtitleQ", StrFix(title, "", 30), @false)
           BinaryWrite(wrtag, "id3v1.tag")
           BinaryFree(wrtag)

           FileAppend("id3v1.tag", tag)
           FileDelete("id3v1.tag")
           Return
; End Script



Article ID:   W14971
File Created: 2001:11:08:12:41:14
Last Updated: 2001:11:08:12:41:14