简体   繁体   中英

Batch file to find specifc filenames inside folders and copy them to other place

I have a directory c:/go, inside go there is tons of folders, subfolders and files.

I need to find inside go, files that start with net*.inf and oem*.inf, and copy the folder, subfolders and all files where they are to another palce at c:/

please help.. thanks

It can also be vbs or any other way to run on the fly using windows...

BAT files are appropiate for iterating over the contents of a directory with the FOR command. See HELP FOR and HELP SET and try this

for /r %%a in (net*.inf) do (
  echo XCOPY %%~pa*.* \destination
)

Repeat the same for oem*.inf or any other specifications you need.

After testing, remove the ECHO and adjust the XCOPY parameters to your appropiate requirements.

EDIT: per OPs comments, changed %%~fa to %%~pa to copy the complete folder content,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM