Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to turn a relative path into an absolute path?

132 views
Skip to first unread message

Dennis Halver

unread,
Jul 7, 2009, 11:13:29 AM7/7/09
to
Assume I start a DOS batch script which can be stored in various directories
on various computers.

One of the first instructions is:

set basedir=%~dp0\..\..

How can I turn/convert this relative path into an absolute path (with no ".." back parent references)?

Dennis

Richard Bonner

unread,
Jul 9, 2009, 7:45:17 PM7/9/09
to
Dennis Halver (ha...@persrec.com) wrote:

> set basedir=%~dp0\..\..

> Dennis

*** XSET can handle that. Use its "/Word" and "/Separator" features to
parse the string to include everything except the `\..\..'.

...something as:

ECHO set basedir=%~dp0\..\.. | XSET /SEPARATOR " \" /WORD 2 BASEDIR
SET basedir=%BASEDIR%

One or more links to websites
for the referred program(s)
can be found at:

http://www.chebucto.ca/~ak621/DOS/Websites.html


Richard Bonner
http://www.chebucto.ca/~ak621/DOS/

Richard Bonner

unread,
Jul 15, 2009, 8:15:01 AM7/15/09
to
CORRECTION:

Richard Bonner (ak...@chebucto.ns.ca) wrote:
> Dennis Halver (ha...@persrec.com) wrote:
(Snip)
> > set basedir=%~dp0\..\..

> > How can I turn/convert this relative path into an absolute path (with no
> > ".." back parent references)?

> > Dennis

> *** XSET can handle that. Use its "/Word" and "/Separator" features to
> parse the string to include everything except the `\..\..'.

> ...something as:

> ECHO set basedir=%~dp0\..\.. | XSET /SEPARATOR " \" /WORD 2 BASEDIR
> SET basedir=%BASEDIR%

> Richard Bonner

*** The second line shuld have read:

SET %BASEDIR%


Richard Bonner
http://www.chebucto.ca/~ak621/DOS/

0 new messages