.cmd script to find first Removable USB drive
You can run a diskpart script on the drive afterwards if you add a MyScript.scr file
@echo off
cls
color 1f
set C=1
set USB=
:LOOP
REM use wmic for USB and Removable media detection
wmic DISKDRIVE where deviceid='\\\\.\\PHYSICALDRIVE%C%' get Index, MediaType, InterfaceType 2>nul | find "Removable" | find /i "USB" > nul && set USB=%C%
set /a C=%C%+1
if %C% GEQ 27 goto :FIN
if not "%USB%"=="" goto :FIN
goto :LOOP
:FIN
set /a USB=%USB%+0
echo First Removable-type USB found=%USB%
if "%USB%"=="" goto :EOF
if %USB% LEQ 0 goto :EOF
(echo sel disk %USB% & echo det disk) | diskpart
echo.
echo.
set ask=
set /p ask=Is disk %USB% OK to ERASE? (Y/N) :
if /i not "%ask%"=="Y" goto :EOF
echo Wiping disk %USB%...
if exist MyScript.scr diskpart /s MyScript.scr
echo Finished!