Dela via


Chdir (Cd)

Displays the name of the current directory or changes the current folder. Used with only a drive letter (for example, chdir C:), chdir displays the names of the current drive and folder. Used without parameters, chdir displays the current drive and directory.

Syntax

chdir [[/d] [Drive**:][Path] [..]] [[/d] [Drive:][Path] [..**]]

cd [[/d] [Drive**:][Path] [..]] [[/d] [Drive:][Path] [..**]]

Parameters

/d   : Changes the current drive or the current directory for a drive.

[ drive : ][ Path ] : Specifies the drive (that is, if it is different from the current drive) and directory to which you want to change.

[ .. ] : Specifies that you want to change to the parent folder.

/?   : Displays help at the command prompt.

Remarks

  • Working with command extensions

    With command extensions enabled (that is, the default), the current directory path matches the folder names exactly as they appear on your hard drive, using the same uppercase or lowercase folder-name format. For example, if the folder on your hard drive is called C:\Temp, CD C:\TEMP sets the current directory to C:\Temp to match the folder-name format of the folder on your hard drive.

    To disable command extensions for a particular process, type:

    cmd e:off

    When you disable command extensions, chdir does not treat white spaces as delimiters. As a result, you can change to a subdirectory name that contains a white space without having to surround [Path] in quotation marks. For example, the following path changes to the \Start menu subdirectory:

    cd \winnt\profiles\username\programs\start menu

    For more information about enabling and disabling command extensions, see cmd in Related Topics.

  • Changing to the root directory

    The root directory is the top of the directory hierarchy for a drive. To return to the root directory, type:

    cd\

  • Changing the default directory on one drive from another drive

    To change the default directory on a drive different from the one you are on, type one of the following:

    chdir [Drive**:\**[directory]]

    cd [Drive**:\**[directory]]

    To verify the change to the directory, type one of the following:

    chdir [Drive**:**]

    cd [Drive**:**]

  • The chdir command, with different parameters, is available from the Recovery Console.

Examples

When you use it with a drive name, chdir displays the current directory for that drive. For example, if you type cd c: at the C:\Temp directory prompt, the following appears:

C:\Temp

To change your current directory to a directory named Reports, type one of the following commands:

chdir \reports

cd \reports

To change your current directory to a subdirectory \Specials\Sponsors, type:

cd \specials\sponsors

Or, if your current directory is \Specials, type the following command to change to the \Specials\Sponsors subdirectory:

cd sponsors

To change from a subdirectory to its parent directory, type:

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 drive B, typing chdir the following appears:

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:

chdir c:\public\jones

copy c:*.* d:\

chdir c:\public\lewis

copy c:*.* d:\

If you want to copy all files in the \Public\Jones and \Public\Lewis directories to your current location on drive D, type:

chdir c:\public\jones

copy c:*.* d:

chdir c:\public\lewis

copy c:*.* d:

Formatting legend

Format

Meaning

Italic

Information that the user must supply

Bold

Elements that the user must type exactly as shown

Ellipsis (...)

Parameter that can be repeated several times in a command line

Between brackets ([])

Optional items

Between braces ({}); choices separated by pipe (|). Example: {even|odd}

Set of choices from which the user must choose only one

Courier font

Code or program output

Mkdir

Cmd

Command-line reference A-Z