Computer Hope

Microsoft => Microsoft DOS => Topic started by: jagdale on September 20, 2004, 01:35:50 PM

Title: getting a file's directory
Post by: jagdale on September 20, 2004, 01:35:50 PM
Hi all,

I have a file called myfile.bat in the C:\A\B directory.  The file is normally run from C:\A not the file's directory of C:\A\B.  I want to set a variable within myfile.bat to know that it is in C:\A\B.  How do I do this?  

When I try %cd% I always get "C:\A" since that's the working directory.

Any help would be appreciated.  FYI, I am using Windows XP.

Thanks,
Ajit

Title: Re: getting a file's directory
Post by: scruge on October 24, 2004, 08:52:42 AM
use the "if exist c:\a\b\myfile.bat "

then take some action based on findings

Title: Re: getting a file's directory
Post by: scruge on October 24, 2004, 08:57:16 AM
forgot to set the variable..

"if exist c:\a\b\myfile.bat set filefound = T "

now the variable %filefound% contains the result.