Skip to content

Instantly share code, notes, and snippets.

@RajdeepKonwar
Last active March 26, 2021 04:18
Show Gist options
  • Save RajdeepKonwar/6c5c0893f0e82cefd062aec73702424d to your computer and use it in GitHub Desktop.
Save RajdeepKonwar/6c5c0893f0e82cefd062aec73702424d to your computer and use it in GitHub Desktop.
Plays random video file in a folder (and sub-folders) using VLC. Skips already played video file.
@echo off
setlocal EnableDelayedExpansion
set n=0
for /r %%f in (*) do (
set /A n+=1
set file[!n!]=%%f
)
:loop
set /A rand=(n*%random%)/32768 + 1
set fff=!file[%rand%]!
for /f "tokens=*" %%x in (randomTV.txt) do if !fff! EQU %%x goto loop
if /I %fff:~-4% EQU .3g2 goto play
if /I %fff:~-4% EQU .3gp goto play
if /I %fff:~-4% EQU .asf goto play
if /I %fff:~-4% EQU .avi goto play
if /I %fff:~-5% EQU .divx goto play
if /I %fff:~-3% EQU .dv goto play
if /I %fff:~-4% EQU .flv goto play
if /I %fff:~-4% EQU .m1v goto play
if /I %fff:~-4% EQU .m2v goto play
if /I %fff:~-5% EQU .m2ts goto play
if /I %fff:~-4% EQU .m4v goto play
if /I %fff:~-4% EQU .mkv goto play
if /I %fff:~-4% EQU .mov goto play
if /I %fff:~-6% EQU .mpeg1 goto play
if /I %fff:~-6% EQU .mpeg2 goto play
if /I %fff:~-5% EQU .mpeg goto play
if /I %fff:~-4% EQU .mp4 goto play
if /I %fff:~-4% EQU .mpg goto play
if /I %fff:~-4% EQU .mts goto play
if /I %fff:~-4% EQU .ogv goto play
if /I %fff:~-5% EQU .rmvb goto play
if /I %fff:~-3% EQU .ts goto play
if /I %fff:~-4% EQU .wmv goto play
goto loop
:play
echo Now playing: %fff%
"C:\Program Files\VideoLAN\VLC\vlc.exe" "%fff%"
if errorlevel 1 "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" "%fff%"
if errorlevel 1 (
echo Please install VLC and retry
pause
exit 0
)
echo %fff%>> randomTV.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment