Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Mine
Tuesday, June 12th, 2007 at 12:59:04pm MDT 

  1. #!/usr/bin/php
  2. <?php
  3.  
  4. $var = $argv[1];
  5.  
  6. if($var == "--help" || strlen($var) == 0){
  7.         echo "WMA to MP3 conversion program\n";
  8.         echo "Daniel Moree\n";
  9.         echo "Version 1.0.0\n\n";
  10.         echo "How to use:\n";
  11.         echo "musicconvert [WMADIR]      Location to search for WMA files\n\n";
  12.         echo "Example:\n";
  13.         echo "      musicconvert /home/Daniel/Music\n";
  14.         exit();
  15. }
  16.  
  17. echo "Getting File list...";
  18. exec("find ".$var." -name '*.wma'", $filelist);
  19. echo "[DONE]\n";
  20.  
  21. if(count($filelist) == 0){
  22.         echo "No files found for conversion!\n";
  23.         exit();
  24. }
  25.  
  26. $time = count($filelist) * 40;
  27. $secs = $time % 60;
  28. $mins = ($time/60) % 60;
  29. $hours = (($time/60)/60) % 60;
  30.  
  31. echo "It should take about $hours hour(s), $mins minute(s), and $secs second(s) to convert all music.\n";
  32.  
  33. $starttime = time();
  34. for($i = 0; $i < count($filelist); $i++){
  35.         echo "Converting File ".($i+1)." of ".count($filelist)."\n";
  36.         $oldfilename = trim(substr($filelist[$i], strrpos($filelist[$i], '/')+1, -3));
  37.         $dirname = trim(substr($filelist[$i], 0, strrpos($filelist[$i], '/')));
  38.         $mplayercmd = "mplayer -ao pcm:file=\"".$dirname."/audiodump.wav\" \"".$filelist[$i]."\" >& /dev/null\n";
  39.         $lamecmd = "lame -b 128 -h \"".$dirname."/audiodump.wav\" \"".$dirname."/".$oldfilename."mp3\" >& /dev/null\n";
  40.         $cleanupcmd = "rm -rf \"".$dirname."/audiodump.wav\" \"".$filelist[$i]."\" >& /dev/null\n";
  41.         exec($mplayercmd);
  42.         exec($lamecmd);
  43.         exec($cleanupcmd);     
  44. }
  45. $stoptime = time();
  46.  
  47. echo "Finished!\n";
  48.  
  49. $totaltime = $stoptime-$starttime;
  50. $secs = $totaltime % 60;
  51. $mins = ($totaltime/60) % 60;
  52. $hours = (($totaltime/60)/60) % 60;
  53.  
  54. echo "Process took $hours hour(s), $mins minute(s), and $secs second(s)\n";
  55.  
  56. ?>

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right
fantasy-obligation