1

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
  • using coding or just to learn where it is? Commented Apr 7, 2010 at 9:25
  • I'm writing a windows batch file. Need to convert the path stored in variable 'filePath' to its fullpath (physical path). Commented Apr 7, 2010 at 11:31

1 Answer 1

4

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).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.