Expand current directory

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ngusaomanoi
Posts: 8
Joined: 13 Nov 2012 20:27

Expand current directory

#1 Post by ngusaomanoi » 13 Nov 2012 20:34

Sorry every one.
I'm beginner at dos don't have experience.I have a problem.

file.xml c:\temp\stylesheets\Part\file.xml

file.bat in c:\temp\stylesheets\file.bat

So i want read file.xml from file.bat but i use path %~dp0\Parts\file.xml.The path don't work.
can i give me advice

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Expand current directory

#2 Post by Ed Dyreen » 13 Nov 2012 21:10

ngusaomanoi wrote:file.xml c:\temp\stylesheets\Part\file.xml

file.bat in c:\temp\stylesheets\file.bat

So i want read file.xml from file.bat but i use path %~dp0\Parts\file.xml.The path don't work.
Show the output of this command, and always add double quotes on paths in batch.

Code: Select all

@echo off &setlocal disableDelayedExpansion
echo.if exist "%~dp0\Parts\file.xml"
if exist "%~dp0\Parts\file.xml" (
        echo.exists
) else echo.notExists
pause

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Expand current directory

#3 Post by Squashman » 13 Nov 2012 21:26

ngusaomanoi wrote:Sorry every one.
I'm beginner at dos don't have experience.I have a problem.

file.xml c:\temp\stylesheets\Part\file.xml

file.bat in c:\temp\stylesheets\file.bat

So i want read file.xml from file.bat but i use path %~dp0\Parts\file.xml.The path don't work.
can i give me advice

Is that a typo?
Part or Parts?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Expand current directory

#4 Post by foxidrive » 13 Nov 2012 23:27

Whichever it is, use a relative path:

.\part\file.xml

or just

part\file.xml

ngusaomanoi
Posts: 8
Joined: 13 Nov 2012 20:27

Re: Expand current directory

#5 Post by ngusaomanoi » 13 Nov 2012 23:47

Thanks you foxidrive it help my software active.
I think should use .\part\file.xml when i send file.bat another computer

Thanks you so much Ed Dyreen your source help me know where i have problem
because when i use %~dp0\Parts\file.xml -> directory\\parts\file.xml
i balance "\" this is reason my path don't work.

Once again thanks all people. :wink:

Post Reply