@echo off &setlocal enabledelayedexpansionset "dd=%date:~2,2%%date:~5,2%%date:~8,2%"for /f "delims=" %%a in ('dir /a-d /b *.txt ^| findstr /v "B[0-9][0-9][0-9]"') do ( set /a num=!random!%%1000 ren "%%~a" "%%~naB%dd%!num!%%~xa" )