Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: getting a file's directory  (Read 3042 times)

0 Members and 1 Guest are viewing this topic.

jagdale

  • Guest
getting a file's directory
« 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


scruge

  • Guest
Re: getting a file's directory
« Reply #1 on: October 24, 2004, 08:52:42 AM »
use the "if exist c:\a\b\myfile.bat "

then take some action based on findings


scruge

  • Guest
Re: getting a file's directory
« Reply #2 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.