批处理实现搜索制定盘下指定文件复制到特定文件夹

setlocal enabledelayedexpansion
@echo off
rem 指定待搜索的文件
set "FileName=test.txt"
rem id = 0
echo 正在搜索,请稍候...
for %%a in (C) do (
  if exist %%a:\ (
    pushd %%a:\
    for /r %%b in (*%FileName%) do (
      if /i "%%~nxb" equ "%FileName%" (
        echo,%%b
    copy %%b "c:/tt/test!id!.txt"
    set /a id = id + 1
      )
    )
    popd
  )
)

猜你喜欢

转载自blog.csdn.net/imgsq/article/details/51481248