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:
Without having to have another batch file to pass arguments to (and use the argument operators), you can use FOR /F
:
FOR /F %%i IN ("..\relativePath") DO echo absolute path: %%~fi
where the i
in %%~fi
is the variable defined at /F %%i
. eg. if you changed that to /F %%a
then the last part would be %%~fa
.
To do the same thing right at the command prompt (and not in a batch file) replace %%
with %
...