Advertisement
contr0l

/ezm3u

Dec 29th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 3.81 KB | None | 0 0
  1. ;Version Check, per file handling commands. If your not on 6.12, you can still use the old method (www.heres.onedumb.com/ezm3u-old.mrc) This is just more than 50% to 70% faster!
  2. on *:load:if $version < 6.12 { echo -a * You must have the latest version of mirc to run /ezm3u - 12www.mirc.com ... Unloading... | unload -rs $script }
  3. /*
  4. /ezm3u by contr0l
  5.  
  6. -Usage: /ezm3u <-ecrn> ::  Will prompt you to select a folder of mp3's and create a .m3u file from the contents. (named according to the dir you choose)
  7. For making m3u's for your albums that dont have an m3u. Pick the album's folder, and hit Go ;)
  8. --Syntax: /ezm3u <-ecrn> :: *switches are optional*
  9. ---Switches:
  10. ----:  -c  ;Clears the cached start dir
  11. ----:  -e  ;Executes the .m3u upon creation, which will run it in your default mp3 player.
  12. ----:  -rn ;this will Run your m3u in Notepad upon creation.
  13. Notes:
  14. The first time ran, the $sdir will start in your c:\ or most likely main drive...
  15. After it has been run once, it will remember the last path, and start there.
  16. Use /ezm3u -c to clean up the cached start dir
  17.  
  18. Updates:
  19. - now uses file handling commands
  20. - eliminated one of the $findfiles
  21. - changed $iifs to regular if statements
  22. - changed so that the benchmark is more accurate
  23.  
  24. If anyone knows of different types of m3u's or anything related to this snippet that can help, plz let me know.
  25. [tested in winamp and musicmatch]
  26.  
  27. heres the work...
  28. */
  29.  
  30. alias ezm3u {
  31.   ;make sure is used as /ezm3u and not $ezm3u
  32.   if !$isid {
  33.     ;if the -c switch is supplied, clear the cached start dir.
  34.     if $1 && $left($1,1) == - && $+(*,c,*) iswm $1 { unset %ez.* }
  35.     ;Prompt for a directory to create the .m3u from.
  36.     ;set the directory they chose to a var..
  37.     set %ez.p $$sdir($iif(%ez.p,$"($ifmatch),$c),Select a folder with the mp3's you want to make a .m3u from.,Go)
  38.     ;error checking
  39.     if $isdir($"(%ez.p)) {
  40.       set %ez.tix $ticks
  41.       ;this sets a variable to the name of the folder you selected .m3u
  42.       set %ez.f $"($+(%ez.p,$gettok(%ez.p,$numtok(%ez.p,92),92),.m3u))
  43.       ;if the m3u already exists in the folder you chose, halt
  44.       if $isfile(%ez.f) { echo -a $+([,$nopath(%ez.f),]) already exists in $+([,$nofile(%ez.f),]) | halt }
  45.       ;else
  46.       ;status track
  47.       set %ez.c 0
  48.       ;fopen the m3u file to /fwrite to it
  49.       .fopen -n ez %ez.f
  50.       ;check that there is atleast 1 mp3 in the specified dir .. and instead of a while loop.. uses findfile, and calls /ez.go $1- on each item found
  51.       if $findfile($"(%ez.p),*.mp3,0,0,ez.go $1-) {
  52.         ;...
  53.         if $isfile(%ez.f) && %ez.c > 0 { echo -a $+([,%ez.f,]) Successfully created in $calc($ticks - %ez.tix) ms! }
  54.         ;[Switch checking]
  55.         if $1 && $left($1,1) == - {
  56.           ; -c switch is checked before anything, to clear the cached dir before running
  57.           if $+(*,e,*) iswm $1 { run %ez.f }
  58.           if $+(*,rn,*) iswm $1 { run notepad %ez.f }
  59.         }
  60.         ;fclose the m3u file after writing to it.
  61.         .fclose ez
  62.         ;cleanup
  63.         unset %ez.c
  64.         unset %ez.tix
  65.         unset %ez.f
  66.       }
  67.       ;error responses
  68.       else echo -a * No .mp3 files in the specified folder.
  69.     }
  70.     else echo -a * You must select a valid directory to continue.
  71.   }
  72.   else return * Insufficient Format: /ezm3u <-ecrn>
  73. }
  74. ;findfile alias
  75. alias -l ez.go {
  76.   var %ez.ff
  77.   ;create the file before writing to it (dir name.m3u .. located in the dir you chose)
  78.   ;use addtok to add each result from the findfile to a var, seperated by chr(13)
  79.   %ez.ff = $addtok(%ez.ff,$nopath($"($1-)),$chr(13))
  80.   ;write the info to the file
  81.   if !$ferr { inc %ez.c | .fwrite -n ez %ez.ff }
  82. }
  83. ;quick alias to wrap in "'s
  84. alias -l " return $+(",$1-,")
  85. ;alias to return a starting point
  86. alias -l c { if $disk(c:) { return c:\ } | else { return $left($mircdir,3) } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement