|Please forgive me for reposting this content, but the subject line I provided gives no clue to what I actually wanted.|
What I'm trying to do is write a batch file that will randomly select a wav file and pass the name to a program called playwav.exe to play. I'll drop a shortcut to the batch file into my Startup folder. I searched this site and found one solution by Mechanix2go that works for me with only very minor modifications (http://www.computing.net/answers/programming/batch-select-random-file/15002.html). So far, here is my solution:
set /a rand=%random%%%37+1
for /f "delims=*" %%1 in ('dir /a-d /b *.wav') do (
set /a nbr+=1
if !nbr! gtr !rand! goto :getout
xcopy /y "%file%" D:\Users\IDigWeeds\Sounds\StartUp\MyStartUp.wav
One thing stilll bothers me... my collection is ever expanding, and editing the random variable to fit my colllection is not satisfactory. How can I modify this file to make it count up the number of files in the directory and use that to seed my random variable?