我想在所有驱动器中搜索一个文件夹,我想使用命令提示符获取文件夹的完整路径名。我该怎么做?
基本上我想找到文件夹“opencv \ build \ bin”的位置并相应地设置环境变量。
提前致谢。
答案 0 :(得分: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"
)