CHDIR – This command-line tool changes Directory, move to a specific Folder. CHDIR is the equivalent word of CD. And the CHDIR is an internal command.
CMD Line is a text-based interface that transfers the command from the user to the OS.
The command-line interpreter (CLI) for windows is CMD.EXE. Also, you can use PowerShell which can automize many system administration tasks and these tasks are not approachable in command prompt. With the help of the CLI, you can communicate with your system by typing the text in commands. As a result, your system answers to the text that you have typed previously, and then the user can proceed with the next command line that shows up.
Run command window helps you to run programs, open the files and folders. And there are several ways to open up the run command dialog box. This run command box is useful for you to head straight to the destined program easily.
By using the Keyboard shortcut Key:
The shortcut key method to the run command box is the most commonly used one. Also, this method is in all versions of Windows. You need to press the Windows+ R key concurrently to open the Run command dialog box.
As we have mentioned previously in this article, this CHDIR command displays the name of or changes the current directory. Also, the CHDIR is an internal command.
CD [/D] [drive:][path] CD [..]
- To change the current DRIVE in addition to changing folder.
By entering simply the part of the path and pressing TAB , Tab completion allows modifying the current folder.
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.
C:> CD Prog [PRESS TAB] Will go to C:\Program Files\
And the Tab Completion is switched on by setting the registry value shown below
REGEDIT4 [HKEY_CURRENT_USER\Software\Microsoft\Command Processor] "CompletionChar"=dword:00000009
- In MS-DOS , each drive had its own current directory , for multiple reasons.
- In win32 there is one global current directory, but at the command line the appearance is still maintained that each drive has its own current directory, this is a fake-out by cmd.exe. The location for each drive is stored using the undocumented environment variables =A:, =B:, =C: etc.
- GUI Windows applications may have a different current directory than the command prompt. Similarly, two CMD sessions can each have a different current directory.
%Error level% =0 – If the Current directory was changed.
%Error level% =1 – In case if the Directory does not exist or is not available or if a bad switch is given.
To change to the parent directory
C:\Work> CD ..
To modify to the grant-parent directory
C:\Work\backup\January> CD ..\..
In order 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
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"
In a batch file to CD to the location of the batch script file (%0)
C:\> CD /d "%~dp0"
To move down the folder tree with a full path reference to the ROOT folder
C:\windows> CD \windows\java C:\windows\java>
For to move down the folder tree with a reference RELATIVE to the current folder
C:\windows> CD java C:\windows\java>
To move up and down the folder tree in one command
C:\windows\java> CD ..\system32 C:\windows\system32>
If the command extensions are enabled, the CHDIR command is enhanced as follows:
- The current directory string is not CASE sensitive.
- So CD C:\windows will set the current directory to C:\Windows
CHDIR does not treat spaces as delimiters , so it is possible to CHDIR into a subfolder name that contains a space without surrounding the name with quotes.
cd \My folder cd "\My folder"
An asterisk can be used to complete a folder name
Example: C:> CD pro* will move to C:\Program Files
To enter the drive letter followed by a colon
C:> E: E:>
In order to change the drive and directory at the same time, use CD with the /D switch
C:> cd /D E:\utils E:\utils\>
In this article, we have seen about the CHDIR command which Change Directory. If you have any suggestions or queries, let us know in the comment section.
- CD This windows command-line tool changes the directory and moves to the specific folder. CHDIR is the equivalent word of CD.
- CMD CMD windows command is to start a new shell in a command or executable program.
- Attrib The Attrib command-line tool is to display or change the file attributes.
- CHDIR The CHDIR command Changes the Directory and moves to the specific folder.
- CLS CLS command is to erase all characters and graphics from the screen. To be more precise, this command clears the screen.