Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the move command to move files in cmd

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about how to use the move command to move files in cmd. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The use of move is very simple, and the basic format is move A B. Here, A represents the file or folder you want to move, B represents the location where An is saved after it is moved, and A can use relative paths, absolute paths, or even wildcards, but when move performs the function of moving files, B can only be a directory path, not a file path-- it's hard to imagine that you have to move a.txt files to b.txt files How the operating system will feel. For example: move a.txt d:\ test, which means moving the a.txt under the current directory to d:\ test; move c:\ test.txt d:\, which means moving the test.txt files from the root directory of C disk to the root directory of D disk; and move c:\ *. Txt d:\ means moving the text files from the root directory of C disk to the root directory of D disk.

In addition, it is important to note that move cannot move folders across partitions. Thanks to zqz0012005 for reminding me.

As mentioned above, if you want to move a.txt to a b.txt file, the operating system will be very unhappy.

What if you do?

Move a.txt b.txt!

You'll find that the operating system didn't stop you from messing around, and it obeyed your orders, but instead of putting a.txt into b.txt as you expected, a.txt changed its name to b.txt.

It turns out that in commands like move A B, move has the basic function of moving files (folders) as well as the function of renaming files (folders). The specific function depends on the circumstances:

1. If An and B are both folder names, move A to the B directory

2. If An is the file name

When ① B is the folder name, move A to the B directory

When ② B is the file name, An is renamed to B; if B is in a different directory, it means that An is renamed to B while moving A to the same directory as B.

Once you understand these uses of move, it's easy to choose between ren and move when renaming a file: if you just rename a file, you can choose either ren or move, but move seems a little weird. If you want to move the file, but also rename the file, choose move c:\ test.txt d:\ abc\ 1.txt will be written in one step, and first move c:\ test.txt d:\ abc, then ren d:\ abc\ test.txt 1.txt writing will appear tedious, the most undesirable approach is first copy, then del/rd, and then ren, which is the pursuit of code to the most simple people can not tolerate extravagant and wasteful behavior.

Sometimes, the process of move is not plain sailing, and it is more common that there is a file with the same name at the destination and the system cannot find the specified file.

Let's start with the case of files with duplicate names.

If there is a duplicate file, move will not succeed, it will be very considerate to ask you: rewrite × ×? (Yes/No/All): where xx represents the destination file with the same name. If you select Yes, the file with the same name will be overwritten; if you select No, the move operation will be abandoned; if you select All, if a file with the same name exists in the batch move, you will no longer be asked whether to overwrite the file with the same name, but will directly overwrite the file with the same name.

If you find it troublesome to jump out of this prompt, and your real goal is to forcibly overwrite all the duplicate files, just add a / Y switch to move and write it as move / y A B-- in the cmd window, move has a /-y switch by default, that is, the prompt for duplicate files appears by default, but this default switch can be omitted. In batch scripts, move defaults to the / y switch and overwrites the file with the same name without a duplicate prompt, which is the opposite of the situation in the cmd window.

Let's take a look at the situation where the system can't find the specified file.

Sometimes, you will be very strange, when move A B, An obviously exists, why do not know why to remind you: "the system can not find the specified file"? Isn't that a lie?

However, Microsoft is also quite innocent: there are too many mistakes, and I am asked to give a clear and specific reason for each of them. How can I have such great magical powers? It is not easy for us to engage in technology. We can remind you that you can't find the specified document. We have done our best. Please forgive me a little more.

Come on, let's find out why.

It turns out that move does not have the magical power of dir, it cannot recognize files with hidden or system attributes, and it is blind in front of these files, but it cannot be said that move is too incompetent, but for the sake of security, Microsoft restricts many dangerous commands to operate directly on files with hidden or system attributes-- del and ren are all of this virtue. The rd command, however, is an exception, otherwise Microsoft's system would not have been patched.

How to solve this problem?

There is no way, but to honestly use the attrib command to remove the hidden or system properties of these files, and then come to move. As for how to determine which files need to be attrib before move and which files can be directly move when writing batch processing, it does not fall within the scope of this article.

Thank you for reading! This is the end of this article on "how to use move commands to move files in cmd". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report