Double the percent characters %%
on for
loop variables when in a batch script.
for /r "d:\" %%i in (*.inf) do copy /y "%%~fi" "\files"
Recommended for speed:
xcopy D:\*.inf "\files" /S /I /Y
Note The source and target drive cannot be the same for the xcopy method.
Or
for /f "delims=" %%A in ('dir /a-d/b/s D:\*.inf') do copy /y "%%~fA" "\files"