Batch script to Get First Filename from a directory

Viewed 31655

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 ??

2 Answers
Related