Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Shell 

Music Shuffle

I saw another thread about music, so I decided to whip up some code that somebody might appreciate...as a learning tool, it's practically useless otherwise lol.

Code
@echo off
setlocal enabledelayedexpansion
set amnt=0
set last=NONE

call :check mp3
call :check wav

:loop
cls
set /a rnd=%random%%%%amnt%
if %rnd%==%last% goto loop
set last=%rnd%
echo !file%rnd%!
start /min /wait mplay32 /play /close !file%rnd%!
goto loop

:check
for /f "delims=" %%A in ('dir /b /s *.%1') do (
    set file!amnt!="%%~A"
    set /a amnt+=1
)

If you put that in a folder with all your music (even in sub-folders), it will find all of the mp3 and wav files (easily changeable) and add them to a list. Then it takes a random file from the list (avoiding repeating the song) and plays it. It will wait for the file to finish playing, where it then repeats the process.

This should work on Vista, and probably on 7 as well. I know it works on XP, but if it doesn't work on your OS then you can always look at the code and see how it works.
This is pretty cool. I might use this for something later on.
You know what makes me sad? The fact that this thread got only ONE reply. I think this can be a great learning tool for anyone wanting to learn about subroutines and for loops.
Wanna know what makes me sad? The fact that your program doesn't work for me because I don't have Mplay32. :(
(Dec 7, 2013 12:34 AM)ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™ Wrote:  Wanna know what makes me sad? The fact that your program doesn't work for me because I don't have Mplay32. :(

Yeah but mplay is pretty easy to get, this is a nice example for usage, thanks White Light.
(Dec 6, 2013 11:12 PM)White Light Wrote:  You know what makes me sad? The fact that this thread got only ONE reply. I think this can be a great learning tool for anyone wanting to learn about subroutines and for loops.

You just gravedug, but in a good way. People need to see this.
[Image: chain.png]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Katе UptonJul 5, 2019 11:51 AM 6 210 Jul 5, 2019 11:51 AM
Last Post: l0lwtf
[Python] by B0PSFeb 15, 2017 07:11 AM 5 157 Feb 15, 2017 07:11 AM
Last Post: Riԁdle
[C] by Mad HatterNov 23, 2016 06:26 PM 3 419 Nov 23, 2016 06:26 PM
Last Post: REDRIFLE