0

我想在所有驱动器中搜索一个文件夹,如果它存在,我想使用命令提示符获取该文件夹的完整路径名。我该怎么做?

基本上我想找到文件夹“opencv\build\bin”所在的位置并相应地设置环境变量。

提前致谢。

4

1 回答 1

0

看看这是否适合您:它将报告找到的最后一个匹配项。

@echo off
for %%a in (c d e f g h i j k l m n o p q u r s t u v w x y z) do (
   if exist "%%a:\" dir %%a:\ /ad /b /s >>"%userprofile%\desktop\folderlist.txt"
 )

find /i "\opencv\build\bin" < "%userprofile%\desktop\folderlist.txt" >"%userprofile%\desktop\folderlistfound.txt"

if exist "%userprofile%\desktop\folderlistfound.txt" (
  for /f "usebackq delims=" %%a in ("%userprofile%\desktop\folderlistfound.txt") do (
    set "foundfolder=%%a"
    echo found at "%%a"
  )
)
if defined foundfolder (
     echo last folder matched at "%foundfolder%"
  ) else (
     echo didn't find the "opencv\build\bin"
  )
于 2013-08-24T06:53:17.003 回答