我正在执行这样的脚本:
c:tempdir1>c:myprogramscript1.bat .subdir1
现在在我的脚本 1 中.bat我想将参数 (%1) 在本例中为".\subdir1"转换为绝对路径,以便它是 c:\temp\dir1\subdir1。我已经尝试了各种选项,包括 %~dp1,但它在这里没有给我所需的路径。
从 for /?
:
%~fI - expands %I to a fully qualified path name
因此,这应该有效:
for /F %%I in ("%1") do echo %%~fI
实际上你不需要for
,它可以简化为:
echo %~f1