I want to make a batch file that copies *.inf files in hard disc to my pen drive on autorun?

StackOverflow https://stackoverflow.com/questions/22157445

  •  19-10-2022
  •  | 
  •  

Question

Today I was trying to create a batch file which up on execution, searches my d drive for inf files and copies them to my pen-drive files folder. I was trying this code:

for /r "d:\" %i in (*.inf) do copy /y  "%~fi" "\files"

How to put it in a batch file and automate it...

No correct solution

OTHER TIPS

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"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top