批量复制文件

发布于: 雪球转发:0回复:0喜欢:0

问题描述
1、D:\hs(含有子文件夹)
2、需要查找的文件名字列表已经存储在1.txt文档中了。
3、按1.txt文档中文件名字列表批量查找文件,并复制到d:\tmp 中。
4、如果1.txt文档中某个文件没有在D:\文件夹1(含有子文件夹)中找到,将文件名复制到另2.txt



@echo off

call :t D:\tmp\1.txt F:\hs D:\tmp D:\2.txt

goto :eof

:t

for /f "usebackq delims=" %%a in (%1) do (

for /r "%~f2" %%b in (

"%%~nxa"

) do copy "%%~b" %3

if not exist "%~3\%%~nxa" echo %%a >> %4

)

goto :eof