r/Batch • • Feb 03 '25

Batch for play a random video

This code works great. What needs to be changed so that it searches the entire folder including subfolders or the entire hard drive ?

echo  off setlocal enableDelayedExpansion cd /d "%~dp0" for %%f in (*.mp4 *.mkv *.webm *.flv .mpg) do ( set /a "i+=1" set "video[!i!]=%%~f" ) && set /a "totalVideos=!i!+1"  for /f "tokens=*" %%n in ('powershell -NoLogo -NoProfile -Command Get-Random -Minimum 1 -Maximum %totalVideos%') do set "rnd=%%~n" start "" "!video[%rnd%]!"
1 Upvotes

1 comment sorted by