My function needs the first filename from a particular directory to process some tests using the first file, on completing tests delete first file from directory
I tried as below
FOR /R \\<My Folder> %F in (*.zip*) do echo ~nF >%test_list%
set /p firstline=%test_list%
echo %firstline%
FOR /F "tokens=*" %%A IN ('dir %test_firmware_dir% /b/s ^| find /c ".zip"') DO SET
count=%%A
echo %count%
:test_execution
if %count% NEQ 0 (
echo ON
dir /b %test_firmware_dir%\*.zip >%test_firmware_list%
set /p firstline=<%test_firmware_list%
set /a filename=%firstline:~0,-4%
Echo %filename%
Echo *********************************************************
Echo "Now running batch queue tests with %filename%"
Echo ********************************************************
it is showing last element any procedure to get first element ??
An alternative is to use
goto(breaks FOR loops) after you have your first file:And it could run (a little bit) faster in some cases as it doesn’t have to go through the whole directory.