Zend certified PHP/Magento developer

How to get Paul Black’s random file selector batch script not to select itself

I’ve been using Paul Black’s random file selector batch script for a while to handle one aspect of playout on our radio station – and most of the time it works perfectly.

Except on occasion it adds itself, since, of course, it has to be in the same folder. At that point playback stops since .bat is not an audio file.

Here’s the original script which I modified to push a file to our playout via CMD:

@echo off
:: ##############################################################################
:: # Title:      Select a random filename in the current directory [ folder ].  #
:: # Created By: Paul Black at TenForums.com/members/paul-black.html            #
:: # Created:    October 2020.                                                  #
:: ##############################################################################
title Select A Random Filename.
mode con: cols=80 lines=5 & color 17
setlocal EnableDelayedExpansion
set n=0
for %%f in (*.*) do (
  set /A n+=1
  set "file[!n!]=%%f"
)
set /A "RAND=(n*%Random%)/32768+1" & set /A "rand=(n*%Random%)/32768+1"
echo. & echo "!file[%RAND%]!"
echo. & echo ^>Press ANY key to EXIT . . . & pause >nul & exit

So how would I get this to ignore itself, and not choose random.bat?