在批处理文件中,我遍历文件中的 unc 路径列表,使用 pushd 将上下文更改为该位置,然后执行命令。%CD% 给出了上一个目录的位置,而不是当前推送的目录。
for /f "tokens=*" %%A in (filesharelist.txt) do (
pushd %%A
echo CD=%CD% - expecting x:\ or x:\subpath here, but get previous directory
REM xcopy *.xml %DestinationDirectory% /V /C /Y /Z
popd
)
Run Code Online (Sandbox Code Playgroud)
如何获取当前目录?