Hi i am making a batch script with which i want to copy random files from one folder to another everything is working fine but the for loop in section 2 copies all the lines from the text file but i only want to copy the file name of only one selected file
my code
@echo off
:1
set num=0
cls
set /p input=enter the number of total files:
set /p input1= enter the number of files you want:
set /p address= enter the address of your files:
FOR /f "tokens=1*delims=:" %%b IN ('dir /b /a-d "%address%\*" ^|findstr /n /V ":"') DO (ECHO/%%b:%%~fc)>> filename.txt
md SelectedFiles
:2
del File.txt
set /a l= 1+1
set /a num=%num%+1
set /a n=%random% %% %input% +1
set "options=tokens=1* delims=%n%:"
for /f "%options%" %%a in (filename.txt) do if 2==%l% set file=%%b
set file=type file.txt
echo file.txt
copy "%file%" "SelectedFiles"
if %num% lss %input1% goto 2
echo your files have been copied
pause
goto 1