blob: 50610ebdd27f3124a983cc1d9974b018993ba244 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
@echo off
setlocal enabledelayedexpansion
set FOLDER_NEEDLE=%~2
echo looking for ...\%FOLDER_NEEDLE%\
set FOLDER=%~dp0
set LOOP_COUNT=1
:rootloop
if exist "%FOLDER%%FOLDER_NEEDLE%" goto :haverootpath
set FOLDER=%FOLDER%..\
set /a LOOP_COUNT=%LOOP_COUNT%+1
if %LOOP_COUNT% GTR 50 (goto :error)
goto :rootloop
:haverootpath
set FOLDER=%FOLDER%\%FOLDER_NEEDLE%\
pushd %FOLDER%
set FOLDER=%CD%
popd
echo Found %FOLDER%
:manualfolder
set returnVal=%FOLDER%
goto :returnpath
:error
echo Couldn't find folder ...\%FOLDER_NEEDLE%\
set returnVal=error\%FOLDER_NEEDLE%
pause
goto :returnpath
:returnpath
( endlocal
set "%~1=%returnVal%"
)
goto :eof
|