1.

Solve : Storing current directory into a variable?

Answer»

I'm WORKING on a concept script that requires me to save the current directory that the script is being run from in a varible to be used later:

Example

set variable = currdir
...
...(somewhere in here it will TRAVERSE to another directory)
cp somefile %variable%/required_subdirectoryif you need the current directory then use the CD variable.

Code: [Select]set currentdir=%CD%
grimbear, don't use spaces around the equals sign in batch.
Grimbear
You might like to check the 2 commands
PUSHD
POPD

PUSHD saves the current directory when you can go off an do other processing and POPD will then return you to where you started. Quote from: wbrost on April 22, 2010, 08:20:56 AM

if you need the current directory then use the CD variable.

Code: [Select]set currentdir=%CD%

Why do that when you can just use %CD%? Quote from: Helpmeh on April 23, 2010, 04:18:00 AM
Why do that when you can just use %CD%?

because they want to use the current directory at the time they retrieve it later on when it MAY no longer actually be the current directory?

gpl caught ONTO the possible requirement the OP was after- pushd and popd.


Discussion

No Comment Found