Resolve absolute path from relative path and/or file name

前端 未结 14 1792
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 09:38

Is there a way in a Windows batch script to return an absolute path from a value containing a filename and/or relative path?

Given:

         


        
14条回答
  •  误落风尘
    2020-11-27 10:05

    stijn's solution works with subfolders under C:\Program Files (86)\,

    @echo off
    set projectDirMc=test.txt
    
    for /f "delims=" %%a in ('powershell -Command "[System.IO.Path]::GetFullPath( '%projectDirMc%' )"') do @set resolvedPath=%%a
    
    echo full path:    %resolvedPath%
    

提交回复
热议问题