我有这个批次,我试图让父目录保持不变。
@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
.