批处理寻找未知路径并粘贴拷贝的文件

来源:百度知道 编辑:UC知道 时间:2024/09/24 05:32:43
我想用批处理把光盘(盘符不定)上的000.txt文件拷贝到C和D盘中凡是有aaa.exe文件的地方,aaa.exe文件的路径未知,并可能有多个aaa.exe文件存在于不同的路径,都需要粘帖000.txt文件。哪位高手能解决我的问题?谢谢了。

@echo off
setlocal enabledelayedexpansion
call:main
endlocal
goto :eof

:main
set "exe=aaa.exe"
set "txt=000.txt"
call:zhaoguangpan "!txt!"
for %%i in (c d) do (
for /f "delims=" %%j in ('dir /a:-d /b /s %%i:\"!exe!"') do (
copy !answer!:\"!txt!" "%%~dpj"
)
)
exit /b

:zhaoguangpan
set "answer="
for %%i in (e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%i:\%1 (
set "answer=%%i"
exit /b
)
)
exit /b