/mp3sort

By Rebellious on Dec 18, 2007

Sorts mp3 files in a directory based on given parameters. Lists the sorted list in a new window.

; -------------------------------------------
; /mp3sort - Mp3 file sorter 
; Obviously sort mp3 files from a directory

; Can sort based on params:
; - length: Sorts mp3 files based on their length
; - sample: Sorts mp3 files based on their sample rate
; - bitrate: Sorts mp3 files based on their bitrate
; - size: Sorts mp3 files based on their size

; /mp3sort <length/size/bitrate/sample>

; Or you can type /mp3sort and it will sort based on the filename

; Empties the data into a new window in which you view the list.

; Updates/Version history

; *Fixed a few bugs regarding length, bitrate, and sample 
; - Courtesy of EL 

; *Added a file info option. :)

; *Recoded 

; ------------------------------------------

alias mp3sort {  
  :begin
  var %d = " $+ $sdir(C:\,Select a directory) $+ ", %o, %x = 1 
  if (!$(% $+ d,2)) { 
    var %p = $input(No directory selected!,r,error)
    if (%p = $true) goto begin 
  }
  if ($window(@mp3sort)) window -c @mp3sort
  window -hls @mp3sort
  %o = $1  
  if (%o = length) .echo -q $findfile(%d,*.mp3,0,aline @mp3sort $+($sound($1-).length,$chr(9),$1-))
  if (%o = size) .echo -q $findfile(%d,*.mp3,0,aline @mp3sort $+($file($1-),$chr(9),$1-))
  if (%o = bitrate) .echo -q $findfile(%d,*.mp3,0,aline @mp3sort $+($sound($1-).bitrate,$chr(9),$1-))
  if (%o = sample) .echo -q $findfile(%d,*.mp3,0,aline @mp3sort $+($sound($1-).sample,$chr(9),$1-))
  elseif (!$(% $+ o)) .echo -q $findfile(%d,*.mp3,0,aline @mp3sort $+($1-,$chr(9),$1-))
  aline @mp3sort Sorted list for $+(%d,:) based on $iif(!$(% $+ o,2),file name,file %o)
  if ($window(@mp3sorted)) window -c @mp3sorted
  window -l @mp3sorted 
  filter -ww @mp3sort @mp3sorted
}

menu @mp3sorted { 
  $iif(!$sline(@mp3sorted,1),$style(2) View file info,View file info):{ 
    var %g = $gettok($sline(@mp3sorted,1),2-,9)
    aline @mp3sorted Filename: %g
    aline @mp3sorted Size: $bytes($file(%g)).suf
    aline @mp3sorted Length: $duration($calc($sound(%g).length /1000),3)
    aline @mp3sorted Bitrate: $sound(%g).bitrate kbps
    aline @mp3sorted Sample rate: $sound(%g).sample khz
    aline @mp3sorted -------------------  
  }
}

Comments

Sign in to comment.
Rebellious   -  Dec 19, 2007

Thanks a bunch, glad to know it\'s working properly.

 Respond  
EL   -  Dec 19, 2007

All worked for me this time i went over all the commands twice before i posted this and if anyone else finds flaw with this code after this update please post ty.Good work Rebellious nice update.`-.-

 Respond  
Rebellious   -  Dec 19, 2007

See updated code.

 Respond  
EL   -  Dec 19, 2007

sorry for the double but when i \'\'tried\'\' them before i posted the error i did do it correctly and i also tried it many times just to make sure i wasn\'t spent.

 Respond  
EL   -  Dec 19, 2007

Rebellious sorry should have been clearer on my post there.Yes i did try them all \"separately\" and i receive the same error message on each * /aline: insufficient parameters (line 27, script13).And yes your code = your preference all tho maybe adding how to add the no path in ;;\'s on the bottom for coders an testers who don\'t know how is a thought.Good work still.`-.-

 Respond  
Rebellious   -  Dec 18, 2007

.. ;p What /mp3sort <length/size/bitrate/sample> meant is that you could type either one individually. (e.g /mp3sort length or /mp3sort bitrate) And I\'d prefer the fullpath when displaying the info. :)

 Respond  
EL   -  Dec 18, 2007

I didn\'t even test the other commands.The /mp3sort (nothing here) Works.But with /mp3sort <length/size/bit rate/sample> i keep getting the same error * /aline: insufficient parameters (line 27, script13) .Not sure how to fix this myself and may just be me i just rather have you aware.Sorry for the double post.`-.-

 Respond  
EL   -  Dec 18, 2007

Works Well Rebellious not sure what uses it may have.Course everything has a use at some point.Also maybe change it to use $nopath just to make it cleaner.EXP: while ($line(@mp3sort,%x)) {
var %mp3Fsort = $gettok($v1,2-,9)
aline @mp3sorted $nopath(%mp3Fsort))
inc %x
Good work on this 7/10.`-.-

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.