批处理-全盘搜索指定文件并复制到指定目录

2025-02-24 01:58:46
推荐回答(2个)
回答1:

隐藏运行,绝对看不到任何信息

set txt=c:\xxx\& set target=c:\winlog\
c:\xxx\ 记录文件路径的目录
c:\winlog\ 要复制的目标目录

for /f "delims=" %%2 in ('dir /s /b %%1wind.txt')
wind.txt 要搜索的文件

@echo off& if not "%~1"=="wind" mshta vbscript:createobject("wscript.shell").run("""%~f0"" wind",vbhide)(window.close)& exit
setlocal enabledelayedexpansion& set txt=c:\xxx\& set target=c:\winlog\
md %txt%& md %target%
for /f %%1 in ('mountvol^|findstr ":\\"')do for /f "delims=" %%2 in ('dir /s /b %%1wind.txt')do (>>%txt%baidu.txt echo %%2
call :wind %%2
copy "%%~2" "%target%%%~n2!wind!%%~x2")
exit
:wind
if exist "%target%%~n1!wind!%~x1" (set /a wind+=1&& goto :wind)

回答2:

写好了。还有什么问题就HI我吧。

@echo off&setlocal enabledelayedexpansion
set num=0
set /p filename=请输入要查找的文件名[包含文件扩展名]:
set /p newpath=请输入所要拷贝到的指定目录:
if not exist !newpath! md !newpath! 1>nul 2>nul
set zh=!newpath:~-1!
if !zh! NEQ "\" set newpath=!newpath!\
for %%a in (c d e f g h i j k l m n) do (
cd /d %%a:\
for /r . %%i in (*.*) do (
if "%%~ni%%~xi"=="!filename!" set /a num=!num!+1 && copy "%%i" !newpath!%%~ni!num!%%~xi 1>nul 2>nul && echo %%i → %%~ni!num!%%~xi>>!newpath!filecopy.txt
)
)
start !newpath!filecopy.txt