- How to Change Directory in CMD | How to Use CD Command Win 10 [MiniTool News]
- Summary :
- What Is CD Command in Windows?
- How to Change Directory in CMD Windows 10
- How to Change Directory in CMD with CD Command
- Step 1. Open Windows Command Prompt Utility
- Step 2. How to Use CD Command in CMD to Change Directory
- Bottom Line
- ABOUT THE AUTHOR
- How can I return to the previous directory in windows command prompt?
- 4 Answers 4
- md_autoruns.cmd:
- mycd.bat:
- aliases:
- Command Prompt: 11 basic commands you should know (cd, dir, mkdir, etc.)
- 1. How to change the directory (folder) in Command Prompt (CMD)
- 2. How to change the drive in Command Prompt (CMD)
- 3. How to view the contents of a directory in Command Prompt (CMD)
- 4. How to create a new directory with Command Prompt (CMD)
- 5. How to rename files and folders with Command Prompt (CMD)
- cmd cmd
- Синтаксис Syntax
- Параметры Parameters
- Remarks Remarks
How to Change Directory in CMD | How to Use CD Command Win 10 [MiniTool News]
By Alisa | Follow | Last Updated March 04, 2021
Summary :
This tutorial gives a detailed guide on how to change directory in CMD (Command Prompt) in Windows 10 computer. Learn how to use CD command in Windows Command Prompt to access different directories and folders. FYI, MiniTool software designs a free data recovery software program allowing you to recover any deleted/lost files from Windows 10/8/7 computer and other storage devices.
Windows Command Prompt (cmd.exe) lets you do many things quickly on your Windows computer. Wonder how to change directory in CMD? You can use the CD command to easily do this.
What Is CD Command in Windows?
The CD command refers to “change directory”. It is a professional Windows Command Prompt change directory command. You can use CD command to easily change the current working directory in CMD in Windows 10, and open different directories or folders on your Windows 10 computer. Check how to use CD command to change directory in Command Prompt below.
How to Change Directory in CMD Windows 10
- Open elevated Command Prompt
- Use the CD command to change directory in CMD
How to Change Directory in CMD with CD Command
Step 1. Open Windows Command Prompt Utility
Before you use Command Prompt to change directory, you should enter into Command Prompt at first.
You can press Windows + R, type cmd, and press Ctrl + Shift + Enter to open elevated Command Prompt in Windows 10.
Step 2. How to Use CD Command in CMD to Change Directory
Then you can type CD command lines in CMD to change different directory or folder paths.
If you want to go to a specific directory, you can type cd + full directory path, e.g. cd C:\Program Files.
To open a particular folder, you can type cd + full folder path, e.g., cd C:\Program Files\office.
To go up a directory level you are currently working, you can type cd ..
To check the whole subdirectories and folders in the current directory, you can type dir command.
To go to the root level directory from any directory, you can type cd \.
To change the current drive, you can firstly type cd \ to go to the root directory, and then enter the drive letter followed by a colon to enter the target drive, e.g. I:.
To change the drive and directory at the same time, you can use CD and the /D switch simultaneously, e.g., cd /D I:\MiniTool Partition Wizard 11.
Bottom Line
Now you should know how to change directory in Command Prompt (CMD) by using CD command in Windows 10. You can easily access different directories or folders with CD command Windows in Command Prompt.
If you can’t find a file or folder in your Windows 10 computer, you may lost it or mistakenly deleted it, you can easily recover the file or folder with MiniTool Power Data Recovery.
MiniTool Power Data Recovery is a professional free data recovery program compatible with Windows 10/8/7. You can use this software to easily recover data from various data loss situations.
Namely, you can recover any deleted/lost files from Windows 10/8/7 computer, external hard drive, USB/thumb/pen drive, SD card, and more.
For the data loss due to mistaken file deletion, system crash and other computer system issues, hard drive failure, malware/virus infection, etc. you can use MiniTool Power Data Recovery to easily retrieve the lost files and data.
ABOUT THE AUTHOR
Position: Columnist
Alisa is a professional English editor with 4-year experience. She loves writing and focuses on sharing detailed solutions and thoughts for computer problems, data recovery & backup, digital gadgets, tech news, etc. Through her articles, users can always easily get related problems solved and find what they want. In spare time, she likes basketball, badminton, tennis, cycling, running, and singing. She is very funny and energetic in life, and always brings friends lots of laughs.
How can I return to the previous directory in windows command prompt?
I often want to return to the previous directory I was just in in cmd.exe, but windows does not have the «cd -» functionality of Unix. Also typing cd ../../.. is a lot of typing.
Is there a faster way to go up several directory levels?
And ideally return back afterwards?
4 Answers 4
On Windows CMD, I got used to using pushd and popd . Before changing directory I use pushd . to put the current directory on the stack, and then I use cd to move elsewhere. You can run pushd as often as you like, each time the specified directory goes on the stack. You can then CD to whatever directory, or directories , that you want. It does not matter how many times you run CD. When ready to return , I use popd to return to whatever directory is on top of the stack. This is suitable for simple use cases and is handy, as long as you remember to push a directory on the stack before using CD.
Run cmd.exe using the /k switch and a starting batch file that invokes doskey to use an enhanced versions of the cd command.
Here is a simple batch file to change directories to the first parameter (%1) passed in, and to remember the initial directory by calling pushd %1.
md_autoruns.cmd:
We will also need a small helper batch file to remember the directory changes and to ignore changes to the same directory:
mycd.bat:
And a small aliases file showing what to do to make it all work:
aliases:
Now you can go up a directory level by typing ..
Add another . for each level you want to go up.
When you want to go back, type cd — and you will be back where you started.
Aliases to jump to directories like wk or tools (shown above) swiftly take you from location to location, are easy to create, and can really help if you work in the command line frequently.
Command Prompt: 11 basic commands you should know (cd, dir, mkdir, etc.)
Geeks and experts love the Command Prompt because of the advanced commands it can run. Fortunately, Command Prompt is not built only on advanced commands, but also on simple ones, designed to perform basic operations. In this article, we show you how to execute commands such as changing the current directory, switching to another drive, viewing the contents of a directory, creating and renaming folders, copying, deleting files and folders, and launching applications from the Command Prompt. We are also going to show you how to get help when using this app for Windows. Let’s get started:
NOTE: The information shared in this tutorial applies to Windows 10, Windows 8.1, and Windows 7. Note that, for simplicity, we are using screenshots taken only in Windows 10.
1. How to change the directory (folder) in Command Prompt (CMD)
The first command from the list is CD (Change Directory). This command enables you to change the current directory or, in other words, to navigate to another folder from your PC. For instance, the command CD takes you to the top of the directory tree. To see how it works, after you open the Command Prompt, type cd and press Enter on your keyboard. You should see how the CD command takes you to the top of the directory tree. In this case, to the “C:” drive.
Note that the Command Prompt is not case sensitive, meaning that you can type commands using capital letters, lowercase or any combination of them. The commands CD, cd or Cd, all work the same way.
Going back to the “CD” command, now you are working on the root of the “C:” drive. If you need to go to a specific folder from this drive run the command “CD Folder.” The subfolders must be separated by a backslash character: “.” For instance, when you need to access the System32 folder located in “C:\Windows,” type “cd windows\system32” as shown below, and then press Enter on your keyboard.
When you need to go one folder up, use the “cd..” command. Let’s assume that you want to go back to the Windows folder. Type “cd..” and press Enter on your keyboard.
The effect is that your current directory changes to “C:\Windows.”
2. How to change the drive in Command Prompt (CMD)
To access another drive, type the drive’s letter, followed by “:”. For instance, if you wanted to change the drive from “C:” to “D:”, you should type “d:” and then press Enter on your keyboard.
To change the drive and the directory at the same time, use the cd command, followed by the “/d” switch. The “/d” parameter is used to change the current drive to a specific folder from another disk volume.
For instance, if you are now on the “D:” drive and you want to go back to the Windows folder from the”C:” drive, you should type “cd /d C:\Windows” and press Enter on your keyboard, like in the following screenshot.
NOTE: By typing only the drive letter you automatically move to your most recent location on that drive. For instance, if you are on “D:” drive and type “cd c:\windows” nothing seems to happen. However, if you type “c:” then the working folder changes to “c:\windows,” assuming that it was the last folder you worked with on your “C:” drive.
3. How to view the contents of a directory in Command Prompt (CMD)
You can view the contents of a folder by using a command called DIR. To test it, we have created a folder named Digital_Citizen on the D: drive, with several files and subfolders. You can see them in the screenshot below.
The last time, our working folder was “C:\Windows.” To navigate to the folder mentioned above, we have to use the command “cd /d D:\Digital_Citizen.” To view the contents of the folder, type DIR, and press Enter. The list of the files and folders contained by it is displayed, together with some details about each of them (the size and the date and time when they were last modified).
4. How to create a new directory with Command Prompt (CMD)
You can make a new folder using the MKDIR (Make Directory) or the MD command. The syntax of these commands is “MKDIR Folder” or “MD Folder.”
Let’s say we need to create a new folder called Digital_Citizen_Life that is going to be placed in the “D:\Digital_Citizen” folder. To do that, we need to type “mkdir Digital_Citizen_Life” and then press Enter, as shown below.
To test if it worked, use the DIR command again. The newly created folder appears in the list.
NOTE: Do not forget that all these commands depend on the current location in the Command Prompt. For instance, if you are on the “C:” drive and type “MKDIR test,” the new folder is created in the root of the “C:” drive.
Another way to create a folder that does not involve being in the desired folder is to type the complete path of the new folder. For example, if you are working on the “D:” drive and you want to create a new folder in “C:,” called other_stuff, type “mkdir c:\other_stuff” and then press Enter.
When you need to create a folder with subfolders at the same time, you can use the “MKDIR FolderSubfolder” command. For instance, if we type “mkdir Digital_Citizen_Tests\Beta\Test1” three folders are created: Digital_Citizen_Tests, Beta and Test1, in a tree-like structure.
5. How to rename files and folders with Command Prompt (CMD)
To rename files and folders, you need to use the REN (Rename) command. To rename folders, type “ren Folder NewFolderName.” For example, if we wanted to rename the Digital_Citizen_Tests folder to Digital_Citizen_Final_Tests, we should run “ren Digital_Citizen_Tests Digital_Citizen_Final_Tests” and press Enter.
To rename a file, use the same command, like this: “ren filename.extension newname.extension”. For instance, to rename the Digital_Citizen_Picture1.bmp file to Image0.bmp, we have to run the command “ren Digital_Citizen_Image1.bmp Image0.bmp” command.
Read the second page of this tutorial if you want to learn how to copy files and folders, delete files and folders, start an application, and get help when using the Command Prompt.
cmd cmd
Запускает новый экземпляр интерпретатора команд Cmd.exe. Starts a new instance of the command interpreter, Cmd.exe. Если используется без параметров, Команда cmd отображает версию и сведения об авторских правах операционной системы. If used without parameters, cmd displays the version and copyright information of the operating system.
Синтаксис Syntax
Параметры Parameters
Параметр Parameter | Описание Description |
---|---|
/C /c | Выполняет команду, указанную в строке , а затем останавливается. Carries out the command specified by string and then stops. |
/k /k | Выполняет команду, указанную в строке , и продолжит. Carries out the command specified by string and continues. |
/s /s | Изменяет обработку строки после /c или /k. Modifies the treatment of string after /c or /k. |
/q /q | Отключает вывод. Turns the echo off. |
/d /d | Отключает выполнение команд AutoRun. Disables execution of AutoRun commands. |
/a /a | Форматирует выходные данные внутренней команды в канал или файл как Американский национальный институт стандартов (ANSI) (ANSI). Formats internal command output to a pipe or a file as American National Standards Institute (ANSI). |
/U /u | Форматирует выходные данные внутренней команды в канал или файл в Юникоде. Formats internal command output to a pipe or a file as Unicode. |
/t: < | > /t: < | > | Задает цвета фона (b) и переднего плана (f). Sets the background (b) and foreground (f) colors. |
/e: вкл. /e:on | Включает расширения команд. Enables command extensions. |
/e: выкл. /e:off | Отключает расширения команд. Disables commands extensions. |
/f: вкл. /f:on | Включает завершение имени файла и каталога. Enables file and directory name completion. |
/f: выкл. /f:off | Отключает завершение имен файлов и каталогов. Disables file and directory name completion. |
/v: вкл. /v:on | Включает отложенное расширение переменных среды. Enables delayed environment variable expansion. |
/v: выкл. /v:off | Отключает отложенное расширение переменных среды. Disables delayed environment variable expansion. |
Указывает команду, которую требуется выполнить. Specifies the command you want to carry out. | |
/? /? | Отображение справки в командной строке. Displays help at the command prompt. |
В следующей таблице перечислены допустимые шестнадцатеричные цифры, которые можно использовать в качестве значений для параметров и . The following table lists valid hexadecimal digits that you can use as the values for and :
Значение Value | Color Color |
---|---|
0 0 | Черный Black |
1 1 | Синий Blue |
2 2 | Зеленый Green |
3 3 | Aqua Aqua |
4 4 | Красный Red |
5 5 | Сиреневый Purple |
6 6 | Желтый Yellow |
7 7 | Белый White |
8 8 | Серый Gray |
9 9 | Светло-синий Light blue |
а a | светло-зеленый Light green |
b b | Светло-голубой Light aqua |
с c | Светло-красный Light red |
d d | Светло-фиолетовый Light purple |
й e | Светло-желтый Light yellow |
f f | Светлое белое Bright white |
Remarks Remarks
Чтобы использовать несколько команд для , разделите их по разделителю команд && и заключите их в кавычки. To use multiple commands for , separate them by the command separator && and enclose them in quotation marks. Пример: For example:
При указании параметра /c или /k, Команда cmd , оставшаяся часть строки и кавычки сохраняются только при соблюдении всех следующих условий. If you specify /c or /k, cmd processes, the remainder of string, and the quotation marks are preserved only if all of the following conditions are met:
Кроме того, не используется параметр /s. You don’t also use /s.
Вы используете ровно один набор кавычек. You use exactly one set of quotation marks.
В кавычки не используются специальные символы (например, & () @ ^ |). You don’t use any special characters within the quotation marks (for example: & ( ) @ ^ | ).
В кавычках используется один или несколько пробельных символов. You use one or more white-space characters within the quotation marks.
Строка в кавычках — это имя исполняемого файла. The string within quotation marks is the name of an executable file.
Если предыдущие условия не выполнены, строка обрабатывается путем проверки первого символа, чтобы проверить, является ли он открывающей кавычкой. If the previous conditions aren’t met, string is processed by examining the first character to verify whether it is an opening quotation mark. Если первый символ является открывающей кавычкой, он удаляется вместе с закрывающей кавычкой. If the first character is an opening quotation mark, it is stripped along with the closing quotation mark. Любой текст, следующий за закрывающими кавычками, сохраняется. Any text following the closing quotation marks is preserved.
Если не указать параметр /d в строке, Cmd.exe ищет следующие подразделы реестра: If you don’t specify /d in string, Cmd.exe looks for the following registry subkeys:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun\REG_SZ HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun\REG_SZ
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun\REG_EXPAND_SZ HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun\REG_EXPAND_SZ
Если имеется один или оба подраздела реестра, они выполняются перед всеми остальными переменными. If one or both registry subkeys are present, they’re executed before all other variables.
Неправильное изменение реестра может серьезно повредить систему. Incorrectly editing the registry may severely damage your system. Перед внесением изменений следует сделать резервную копию всех ценных данных на компьютере. Before making changes to the registry, you should back up any valued data on the computer.
Вы можете отключить расширения команд для определенного процесса, используя /e: Off. You can disable command extensions for a particular process by using /e:off. Вы можете включить или отключить расширения для всех параметров командной строки cmd на компьютере или сеансе пользователя, задав следующие значения REG_DWORD . You can enable or disable extensions for all cmd command-line options on a computer or user session by setting the following REG_DWORD values:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\EnableExtensions\REG_DWORD HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\EnableExtensions\REG_DWORD
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensions\REG_DWORD HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensions\REG_DWORD
Присвойте параметру REG_DWORD значение 0 × 1 (включено) или 0 × 0 (отключено) в реестре с помощью Regedit.exe. Set the REG_DWORD value to either 0×1 (enabled) or 0×0 (disabled) in the registry by using Regedit.exe. Заданные пользователем параметры имеют приоритет над параметрами компьютера, а параметры командной строки имеют приоритет над параметрами реестра. User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.
Неправильное изменение реестра может серьезно повредить систему. Incorrectly editing the registry may severely damage your system. Перед внесением изменений следует сделать резервную копию всех ценных данных на компьютере. Before making changes to the registry, you should back up any valued data on the computer.
При включении расширений команд затрагиваются следующие команды: When you enable command extensions, the following commands are affected:
assoc assoc
call call
chdir (CD) chdir (cd)
color color
Del (стирание) del (erase)
endlocal endlocal
for for
ftype ftype
goto goto
if if
mkdir (MD) mkdir (md)
popd popd
prompt prompt
pushd pushd
set set
setlocal setlocal
shift shift
Start (также включает изменения во внешние командные процессы) start (also includes changes to external command processes)
При включении отложенного расширения переменных среды можно использовать символ восклицательного знака для замены значения переменной среды во время выполнения. If you enable delayed environment variable expansion, you can use the exclamation point character to substitute the value of an environment variable at run time.
По умолчанию завершение имени файла и каталога не включено. File and directory name completion is not enabled by default. Можно включить или отключить завершение имени файла для определенного процесса команды cmd с параметром /f:<On | Off>. You can enable or disable file name completion for a particular process of the cmd command with /f:<on | off>. Можно включить или отключить завершение имени файла и каталога для всех процессов команды cmd на компьютере или сеанса входа пользователя, задав следующие значения REG_DWORD . You can enable or disable file and directory name completion for all processes of the cmd command on a computer or for a user logon session by setting the following REG_DWORD values:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\PathCompletionChar\REG_DWORD HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\PathCompletionChar\REG_DWORD
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD HKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\PathCompletionChar\REG_DWORD HKEY_CURRENT_USER\Software\Microsoft\Command Processor\PathCompletionChar\REG_DWORD
Чтобы задать значение REG_DWORD , выполните Regedit.exe и используйте шестнадцатеричное значение управляющего символа для конкретной функции (например, 0 × 9 — TAB, а 0 × 08 — это BACKSPACE). To set the REG_DWORD value, run Regedit.exe and use the hexadecimal value of a control character for a particular function (for example, 0×9 is TAB and 0×08 is BACKSPACE). Заданные пользователем параметры имеют приоритет над параметрами компьютера, а параметры командной строки имеют приоритет над параметрами реестра. User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.
Неправильное изменение реестра может серьезно повредить систему. Incorrectly editing the registry may severely damage your system. Перед внесением изменений следует сделать резервную копию всех ценных данных на компьютере. Before making changes to the registry, you should back up any valued data on the computer.
Если включить завершение имен файлов и каталогов с помощью /f: on, используйте сочетание клавиш CTRL + D для завершения имен каталогов и Ctrl + f для завершения имени файла. If you enable file and directory name completion by using /f:on, use CTRL+D for directory name completion and CTRL+F for file name completion. Чтобы отключить определенный символ завершения в реестре, используйте значение пробела [0 × 20], так как оно не является допустимым управляющим символом. To disable a particular completion character in the registry, use the value for white space [0×20] because it is not a valid control character.
При нажатии клавиш CTRL + D или CTRL + F обрабатывается завершение имени файла и каталога. Pressing CTRL+D or CTRL+F, processes the file and directory name completion. Эти функции сочетания клавиш добавляют символ-шаблон к строке (если он отсутствует), формирует список совпадающих путей, а затем отображает первый соответствующий путь. These key combination functions append a wildcard character to string (if one is not present), builds a list of paths that match, and then displays the first matching path.
Если ни один из путей не соответствует, функция завершения имени файла и каталога выдает звуковой сигнал и не изменяет отображение. If none of the paths match, the file and directory name completion function beeps and does not change the display. Для перемещения по списку совпадающих путей нажмите клавиши CTRL + D или CTRL + F несколько раз. To move through the list of matching paths, press CTRL+D or CTRL+F repeatedly. Для перемещения по списку назад нажмите клавишу SHIFT и CTRL + D или CTRL + F одновременно. To move through the list backwards, press the SHIFT key and CTRL+D or CTRL+F simultaneously. Чтобы отменить сохраненный список совпадающих путей и создать новый список, измените строку и нажмите клавиши CTRL + D или CTRL + F. To discard the saved list of matching paths and generate a new list, edit string and press CTRL+D or CTRL+F. Если переключиться между сочетаниями Ctrl + D и CTRL + F, сохраненный список соответствующих путей отбрасывается и создается новый список. If you switch between CTRL+D and CTRL+F, the saved list of matching paths is discarded and a new list is generated. Единственное различие между сочетаниями клавиш Ctrl + d и Ctrl + f заключается в том, что сочетание клавиш Ctrl + d соответствует именам каталогов, а сочетание клавиш CTRL + F соответствует именам файлов и каталогов. The only difference between the key combinations CTRL+D and CTRL+F is that CTRL+D only matches directory names and CTRL+F matches both file and directory names. Если вы используете автозаполнение имен файлов и каталогов во всех встроенных командах каталога (т. е. CD, MD или RD), предполагается завершение каталога. If you use file and directory name completion on any of the built-in directory commands (that is, CD, MD, or RD), directory completion is assumed.
Имя файла и каталога правильно обрабатывает имена файлов, которые содержат пробелы или специальные символы, если они заключены в кавычки для соответствующего пути. File and directory name completion correctly processes file names that contain white space or special characters if you place quotation marks around the matching path.
Необходимо использовать кавычки для следующих специальных символов: & [] | < >^ = ; ! You must use quotation marks around the following special characters: & [ ] | < >^ = ; ! ‘ +, ‘
Если предоставленные сведения содержат пробелы, заключите текст в кавычки (например, «имя компьютера»). If the information that you supply contains spaces, you must use quotation marks around the text (for example, «Computer Name»).
Если обработка имени файла и каталога выполняется из строки, любая часть пути справа от курсора отбрасывается (в точке, где обработано завершение). If you process file and directory name completion from within string, any part of the path to the right of the cursor is discarded (at the point in string where the completion was processed).