新建一下txt文件,把要复制的文件名称写在txt中,search_dir搜索文件路径,保存文件target_dir路径:file_list读取txt路径:
注意:a.txt中要写文件的后缀名称。
脚本内容如下:
@echo off
set search_dir=C:\Users\PC\Desktop\0106
set target_dir=C:\Users\PC\Desktop\22
set file_list=C:\Users\PC\Desktop\0106\a.txt
for /f "tokens=*" %%a in (%file_list%) do (
echo Searching for "%%a"...
for /r "%search_dir%" %%b in ("%%a") do (
echo Copying "%%b" to "%target_dir%"...
xcopy "%%b" "%target_dir%" /y
)
)