switching dirs methods

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
pstein
Posts: 125
Joined: 09 Nov 2011 01:42

switching dirs methods

#1 Post by pstein » 31 Mar 2014 01:01

As far as I know there are two methods on how to switch a dir inside a dos batch script:

@PushD D:\foo\bar

and

cd /d D:\foo\bar

Is there a difference between them?

Peter

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

Re: switching dirs methods

#2 Post by Squashman » 31 Mar 2014 06:32

PUSHD has a lot more functionality. Sometimes you are doing multiple PUSHD commands and you don't want to have to remember what directory you need to change back to so you just issue the POPD command to return to the previous directory in the stack.

Code: Select all

H:\>pushd /?
Stores the current directory for use by the POPD command, then
changes to the specified directory.

PUSHD [path | ..]

  path        Specifies the directory to make the current directory.

If Command Extensions are enabled the PUSHD command accepts
network paths in addition to the normal drive letter and path.
If a network path is specified, PUSHD will create a temporary
drive letter that points to that specified network resource and
then change the current drive and directory, using the newly
defined drive letter.  Temporary drive letters are allocated from
Z: on down, using the first unused drive letter found.

Post Reply