I'm attempting to pick a random 100 songs to copy to my mp3 player so I have something new to listen to each morning without having to drag and drop random files myself (I can't put my entire library on the player at once).
I'm using a bat script to do it but I've encountered a few snags. The one I have below works, but copies ALL the files in a random folder rather than a random file from a random folder before moving on to the next.
I'm a complete novice with this so everything is kinda culled from other solutions on here and bodged together.
echo off
:randomstart
setlocal EnableDelayedExpansion
rem Enter into the directory that contain the folders
pushd D:\test1\
rem Create an array with all folders
set i=0
for /D %%a in (*) do (
set /A i+=1
set folder[!i!]=%%a
)
rem Randomly select one folder
set /A index=(%random%*i)/32768 + 1
rem Copy the desired file
copy "!folder[%index%]!\" "D:\output2\" /Y
rem And return to original directory
popd
ping -n 2 localhost >nul
goto:randomstart
I've also tried adding a for loop to count from 1 to 100 but I can't get my head around it in the slightest. Is there anyone out there that can save this idiot?
I tried asking this on Server fault and was told this would be a better place to ask.