echo off setlocal for %%i IN (e,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) do ( if not defined second (call :TESTDRIVE %%i) else (goto :ALLDONE) ) goto :eof :TESTDRIVE if exist %1: echo %1 is already a driveletter if not exist %1: echo %1 USABLE DRIVELETTER && call :MOUNTDRIVE %1 goto :eof :MOUNTDRIVE if not defined first (set first=%1) else (set second=%1) echo this is where we would mount drive %1 goto :eof :ALLDONE echo All done, first driveletter is %first%, second is %second% endlocal