ここにバッチがあります。親ディレクトリを固定しようとしています。
@echo off
SET CWD=
:process
if [%1] == [] goto end
SET MASTER_DIR="%~f1"
rem Change to say, E:\DVD_LIBRARY\Rips
cd /d %MASTER_DIR%
for /R %%D IN (\) DO (
rem Temporarily change to the subdir, such as E:\DVD_LIBRARY\Rips\SIN_CITY\
pushd %%D
for /F "usebackq" %%Z in (`dir /b *.vob 2^>NUL`) DO (
if exist %%~fZ (
rem Get this parent directory to store the log file in (eventually)
CALL :resolve "%%D\.." CWD
rem Nada.
echo: %CWD%
)
)
popd
)
shift
goto process
:resolve
SET %2=%~f1
goto :EOF
ルーチンでは:resolve
、私が望む値を取得しています。このブロックに戻ります。
if exist %%~fZ (
CALL :resolve "%%D\.." CWD
echo: %CWD%
)
私は何も得ていません。
これが固執しない理由、またはより良い方法はありますか? 私はグーグルを精査し、このテクニックと他のいくつかのテクニックをここで見つけましたが、CALL
.