DOS Directory jump Cd_dos/bat

Source: Internet
Author: User
For example, when we open the Command line window, this is generally the case: in the bottom left corner of the desktop to find the "Start" menu, open "Run", enter "cmd", return. At this point, the default current directory for the command Line window is located under the current user's path, such as C:\Documents and SETTINGS\JM, as shown in the following figure. Generally speaking, this directory does not have the files we want to process, we probably need to jump to other directories, such as: "C packing directory, this time, we need to use a CD to achieve the directory jump: cd C:\."

The full name of the CD is change directory, literal translation is changed folder, that is, jump directory, the meaning of the switch path. It can then be followed by the drive symbol, the full path, and the relative path. It is known from its full name that it cannot manipulate files and can only be used for drives or folders. For example, we use the CD C:\Boot.ini this command to jump (Boot.ini is a file instead of a folder), and a "directory name is invalid" error appears, as shown in the following figure.

If you want to jump to the root directory of the current directory, you can use a simple command: cd\. As shown in the following figure.

Continue to jump, cd c:\windows\temp, jump to temp directory.

At this point, if you want to go back to the previous level of directory windows, you can use this command: CD ... As shown in the following figure.

Think about it if the CD is executed. What's going to happen?

As a result, the table of contents did not jump and did not move in place. As shown in the following figure. Using this principle, you can use Cd.>test.txt to construct 0-byte text files. For more information, please refer to this article: the 2nd of my usual batch processing practical skills. http://bbs.bathome.cn/viewthread.php?tid=939

Originally, in the cmd,. 、.. and \ Represents a relative path,. Is the current directory, ... Is the previous level directory, and \ represents the root directory.

To see a more bizarre phenomenon:

When jumping from the current directory to a different partition path D:\, the CD d:\ did not succeed and the current directory did not change; when a parameter/D was added, the command was executed successfully. Originally, to jump to different partitions, you need to add the mandatory jump parameter/d. However, if you are entering a subdirectory of the current directory, you may not use the/d parameter. This point is very easy to be overlooked by everyone, hoping to arouse enough attention.

Let's look at a more bizarre phenomenon:

Originally, when the current drive letter + colon is entered, the full path to the current directory is displayed, and when the current drive letter + Colon + backslash is entered, it jumps to the root directory of the current path.

Another very valuable use of CDs is to display the current full path, which is typically referenced by%cd%. As shown in the following figure. At this point, the CD will be interpreted as current Directory, that is, "present folder."

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.