Do you have a folder full of movies on your PC, and you never know which movie to watch? Here’s a simple script you can copy into the folder. When you double-click it, it will open a random item in that folder. You can use it for anything, it’s not just limited to movies.
Step 1: Open Notepad
Step 2: Copy this code in:
setlocal EnableDelayedExpansion echo off cls set count=0 for /f "delims=" %%a in ('dir /b *.*') do @( set filename[!count!]=%%a set /a count = count + 1 ) set /a choose = (%random% * 32768 + %random%) %% count set chosen=!filename[%choose%]! echo Picked: %chosen% echo. echo Opening... echo. IF EXIST "%~dp0%chosen%\*" ( explorer.exe "%~dp0%chosen%" ) ELSE ( cmd /C "%~dp0%chosen%" )
Step 3: Save the file as
_ Pick Random.bat in your movie folder. Make sure to select “All Files” in the Save as type field, so that Notepad doesn’t add .txt to the end of the file name.
Done! Now you can double-click the script, and it will open a random file from your folder.