In this tutorial, I will show you two ways to navigate into a directory that has space(s) in its name.
Feel free to use the table of contents menu above to navigate to any part of this tutorial you want.
The cd Command
The cd command, short for “Change Directory,” is a command-line command that enables users to navigate through the file system by changing the current working directory. This means it allows you to move from one folder (directory) to another folder within your computer’s file system.
Changing to a Specific Directory
To move to a specific directory using the cd command, all you have to do is type in the cd command in the terminal, followed by the name of the directory you want to move to. This is what I mean:
> cd directory
where directory: is the name of the directory you want to move to.
Note: The directory you want to move to, has to be accessible from your current directory. If it is not, you’re going to get the “The system cannot find the path specified” error.
If you don’t know the name of the directories that can be accessed from your current directory, you can use the following command to list them out:
> dir /AD /B
Changing to a Specific Directory with a Name Containing Space(s)
In some cases, trying to move into a directory that has a name with spaces may not be possible. That is, If you try the regular “cd directory” command, it will respond with an error. So in order to avoid these errors, here are two ways you can safely use to move into such directories:
- Using the tab completion
- Surrounding the directory name with quotes
Using Tab Completion
This method works almost like an autocomplete feature in command prompt. This is how you can use it:
- Open command prompt.
- Type “cd” (without quotes).
- Hit tab on the keyboard to cycle through the available directories until you reach your desired directory.
- Press the enter key on your keyboard to navigate to the desired directory.
Surrounding the Directory Name with Quotes
To access a directory with spaces in its name using this method, simply type the cd command followed by the directory name enclosed in quotation marks.
This is what I mean:
> cd "directory name with space(s)"
where directory name with space(s): is the name of the directory you want to move to.
Note: Please do not replace double quotes with single quotes in this command. It will not work.