Receive all updates via Facebook. Just Click the Like Button Below

CD - Change Directory,move to a specific Folder - Windows CMD Commands

Kishore | 18:26 | 0 comments


Change Directory - Select a Folder (and drive)

Syntax
      CD [/D] [drive:][path]
      CD [..]

Key
   /D : change the current DRIVE in addition to changing folder.   

Examples

   To change to the parent directory.
   C:\Work> CD .. 
   
   To change to the grant-parent directory.
   C:\Work\backup\January> CD ..\..
   
   To change to the ROOT directory.
   C:\Work\backup\January> CD \ 
   
   To display the current directory in the specified drive. 
   C:\>  CD D: 
   
   To display the current drive and directory.
   C:\Work> CD

   To display the current drive and directory.
   C:\Work> ECHO "%CD%"

   In a batch file to display the location of the batch script file (%0)  
   C:\> ECHO "%~dp0"

   Moving down the folder tree with a full path reference to the ROOT folder...
   C:\windows> CD \windows\java
   C:\windows\java> 
   
   Moving down the folder tree with a reference RELATIVE to the current folder...
   C:\windows> CD java
   C:\windows\java> 
   
   Moving up and down the folder tree in one command...
   C:\windows\java> CD ..\system32
   C:\windows\system32>
If Command Extensions are enabled the CD command is enhanced as follows: 

1) The current directory string is not CASE sensitive. 
So CD C:\wiNdoWs will set the current directory to C:\Windows

2) CD does not treat spaces as delimiters, so it is possible to CD into a subfolder name that contains a space without surrounding the name with quotes. 

For example: 
cd \My folder

is the same as: 
cd "\My folder"

3) An asterisk can be used to complete a folder name
e.g. from C:\

C:> CD pro*
will move to
C:\Program Files 

CHDIR is a synonym for CD

Tab Completion

This allows changing current folder by entering part of the path and pressing TAB

   C:> CD Prog [PRESS TAB] 
   Will go to C:\Program Files\
Tab Completion is disabled by default, it has been known to create difficulty when using a batch script to process text files that contain TAB characters.

Tab Completion is turned on by setting the registry value shown below

REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
"CompletionChar"=dword:00000009

Changing the Current drive

simply enter the drive letter followed by a colon 
C:> E:
E:> 

To change drive and directory at the same time, use CD with the /D switch
C:> cd /D E:\utils
E:\utils\>

Category: ,

This Article Posted by: Kishore Gurram is a Certified WebDesigner and Professional Blogger. Click Here to Know more About Kishore..

0 comments