2014-02-19 70 views

回答

2

給這個運行:

@echo off 
FOR /D /R "N:\somewhere\far\away\" %%A IN (*) DO (
    Pushd "%%A" 
     Echo now in "%%~nxA" 
    popd 
) 
0

您可以添加另一個for循環,着眼於將路徑作爲字符串%%A並抓住最後一個目錄的名稱 -

setLocal enableDelayedExpansion 
FOR /R "N:/somewhere/far/away/" %%A IN (.) DO (
    FOR /F "delims=\" %%B in ("%%~pA") do set dir=%%B 
    Pushd %%A 
    Echo now in !dir! 
) 
相關問題