在試圖集成第三個循環&它支持代碼到現有的 代碼&我已經達到了我的理解極限。我完全失去了在這個複雜的「EnableDelayedExpansion」環境中如何引用 各種變量。嵌套三(3)for循環&EnableDelayedExpansion
此外,應該在每個 For循環或僅在開始&程序結束時打開/關閉「EnableDelayedExpansion」/ endlocal。
:: ------------------ Beg For #1
For /L %%a in (%XBEG%,1,%XEND%) do (
cls
echo : %%a
set L=1
:: ------------------ Beg For #2
For /F "delims=" %%b in (%XDRV%%XPATH%%%a\1dir%%a.txt) do (
set XTITLE=%%b
echo Line !L!: !XTITLE!
If not {!XTITLE!}=={!XTITLE:%XDRV%%XPATH%%%a\!} set XTITLE=!XTITLE:~18,-4!
::
:: ------------------ Beg For #3 --- New code
:: Write title to the xtemp file. Place the redirection
:: symbol, i.e., greater than sign, IMMEDIATELY after vari
:: to avoid a trailing space, i.e., (%vari%>)
echo !XTITLE!> %XDRV%%XPATH%xtemp.txt
:: Get the file size in bytes, each byte = one character
For %%c in (%XDRV%%XPATH%xtemp.txt) do set /a XLEN=%%~zc
:: Subtract 2 bytes, 1 for CR, 1 for LF, from Length
set /a XLEN -=2
cls
echo : ===[ Debug ]======================================
echo - !XTITLE! - has !XLEN! characters.
set /a XPAD=50-!XLEN!
echo - Xpad is !XPAD!
:: Build the Index entry
set XENTRY=%XPADs%%XTITLE%%XPAD%%%a
echo - %XENTRY%
pause
:: remove the xtemp file
del %XDRV%%XPATH%xtemp.txt
set /a L=!L!+1
pause
:: ------------------ end of New code
):: End For #2
)
:: End For #1
:: Clean Up For3
set XTITLE=
set L=
Goto DOS
的 「EnableDelayedExpansion」/ ENDLOCAL當前放置在節目的開始&端 。
這是我的希望,這種情況是有足夠的興趣社區 您的幫助迫切需要&將非常感激。
非常感謝你! U R最友善,並有真正的禮物。 – user1995371