Click to See Complete Forum and Search --> : batch file - getting working directory


Strogian
09-05-2004, 11:12 AM
ok, I've got a windows xp batch file (.cmd) i'm working on, but I don't know how to store the current working directory. (i.e. $PWD in bash) Here's all I could think of, based on the windows help:

cd | set /p pwd=

but that doesn't seem to do anything.

ua549
09-05-2004, 12:16 PM
Pushd will store the current working directory. When you want to go back to it you do a popd.

Strogian
09-05-2004, 01:24 PM
hey that'll be perfect, that's exactly what i wanted it for. :)

edit: Or, wait a minute, That actually wouldn't work. I want something like this:

cd %1
%root%\program.exe

ua549
09-05-2004, 03:51 PM
Explain with a few more details what you are attempting to do.

From what I can see if program.exe is in the path, there is no need for %root%. If %root% is user specified, it can be passed with %2, etc.

Strogian
09-05-2004, 05:56 PM
Right, I have abbreviated things a bit. Maybe this will be more clear:

I can tell you right now that, unless there is a way to retrieve the current working directory, these are the options I will have:

run it like this:
cd \bob\joe\john\programfolder
program \bob\joe\john\programfolder subdir1 subdir2 subdir2\subdir3
, and in the batch file:
cd %2
%1\program *.asd

or run it like this: (which is what I'd want
cd \bob\joe\john\programfolder
program subdir1 subdir2 subdir2\subdir3
, but a bit messy in the batch file:
copy program datafile1 datafile2 datafile3 %2
cd %2
program *.asd
del program datafile1 datafile2 datafile3

That isn't exactly what I'm doing, but has exactly the same requirements. If you could come up with a better third alternative, that would be awesome. :)

ua549
09-05-2004, 06:23 PM
I've got to shut down for Frances. I'll try to get back to you in a day or two. You'll get more help in the coding & scripting forum so I'm moving this thread there.