Index | Syntax | Notes  



CHDIR--Examples

Either of the following commands changes your current directory to the directory named PRIMETIM: chdir \primetim cd \primetim Suppose you have a directory named SPECIALS with a subdirectory named SPONSORS. To change your current directory to \SPECIALS\SPONSORS, type the following command: cd \specials\sponsors Or, if your current directory is \SPECIALS, you can use the following command to change to the \SPECIALS\SPONSORS directory: cd sponsors To change from a subdirectory back to the parent directory, type the following command: cd.. To display the name of the current directory, you can use CHDIR or CD without a parameter. For example, if your current directory is \PUBLIC\JONES on the disk in drive B, type CHDIR to see the following response: B:\PUBLIC\JONES If you are working on drive D and you want to copy all files in the \PUBLIC\JONES and \PUBLIC\LEWIS directories on drive C to the root directory on drive D, type the following commands: chdir c:\public\jones copy c:*.* d:\ chdir c:\public\lewis copy c:*.* d:\ If, instead, you want to copy all files in the \PUBLIC\JONES and \PUBLIC\LEWIS directories to your current location on drive D, type the following commands: chdir c:\public\jones copy c:*.* d: chdir c:\public\lewis copy c:*.* d: For more information on copying files, see the <COPY> command.

Two golden lines

Hi, I just found this one which I think may be one of my better things.
So, I tried to wrote a clear description.

Benny Pedersen, PS: Tested on both DOS622 and Win98 :-)
and BTW.: I don't always tell when my Homepage is updated. Hmmm,

Your current PROMPT can be $p$g and the current location maybe D:\Working\.
Now, If you do something like this:

   PROMPT Something or
   CD \DOS

then both the PROMPT and the current location maybe changed.

Example 1,
   The following two lines created a file named ~exe.bat, which
   restored both the PROMPT and the working location:

   echo PROMPT %prompt%> %temp%.\~exe.bat
   prompt $N:$_CD $P$_:: |echo EXIT|%comspec%/k>> %temp%.\~exe.bat

   Contents something like this:    PROMPT $p$g   was my current PROMPT.
                                    D:            was my current drive
                                    CD D:\BATCH   was my current location
                                    :: EXIT       to be ignored.

So, if you, something or someone changed the PROMPT or the path,
then you can get it all back. Just do like this:

   call %temp%.\~exe.bat

Hint: If you want to execute some file or whatever, then you can
add a filename between the "/kecho." and ">>" like this example:

@echo off
echo PROMPT %prompt%> %temp%.\~exe.bat
prompt $N:$_CD $P$_::|echo EXIT :-)|%comspec% /kecho.:exe>> %temp%.\~exe.bat
   rem
   rem  Do whatever, for example:   CD %TEMP%.\
   rem
for %%v in (call erase) do %%v %temp%.\~exe.bat

   Example 2, something like this:  PROMPT $p$g   was my current PROMPT.
                                    :exe          was between /kecho. and >>
                                    D:            was my current drive
                                    CD D:\BATCH   was my current location
                                    :: EXIT :-)

   Jump to a similar solution, just click here.


-Top- | Syntax | Notes