views:

75

answers:

2

I have a variable define as:

set filePath=".\file.txt"

I'm writing a windows batch file. Need to convert the path stored in variable 'filePath' to its fullpath (physical path).

How can I get the full path of this path? Please help!

+2  A: 

Since your question is tagged "command-line" I assume you want to do this in a Windows bat script. There you can expand a variable to the full path using the following syntax:

%~fI

where I is the name of the variable.

The following script will print you the full path to ".\file.txt":

set filePath=".\file.txt"
for %%F in (%filePath%) do set filePath=%%~fF
echo %filePath%

A full reference of available substitutions is contained in the description of the for command (http://technet.microsoft.com/en-us/library/bb490909.aspx).

0xA3
I'm not looking for a substitutions in for command :(
Nam Gi VU
Yeah, it works!
Nam Gi VU
A: 

in ms-dos chdir give the active path

drorhan
Can you show me how to store the output of 'chdir' command to a variable?
Nam Gi VU