1、
Originally posted by flyinspace at 2007-4-8 18:53:
To be honest, if no command-line parameters are added, this script is basically useless.
From your other replies, it can be seen that you are a person in programming, but saying such a thing is somewhat unexpected. Let's ask: In an object-oriented high-level language, if the properties of the object are not provided for you to select/modify, is the program compiled a crippled thing? Does such a language resemble a castrated eunuch?
2、
When the input is empty, we use
if /i "%source%"=="" goto ***
if /i "%source%"=="%*" goto ***
This is used to solve. .
In this way, when the target does not exist. .
Error information can be obtained in time for correction. .
It can be said that there are several methods to judge whether the input is empty, and error information can be obtained in time. For example, there is also the if not defined statement. The method you provided is indeed feasible in other cases, but you may not have noticed this description in the previous tag segment:
set source=:
:: The above sentence is to lay the groundwork for removing quotes later, the colon must not be omitted; otherwise, an error will occur when pressing Enter when the input is empty.
Specific problems should be analyzed specifically, and should not be confined to a fixed way of thinking.
3、
In addition, when the copied file is running or occupied.
Did the landlord consider writing to the log (giving a prompt) and then continuing or stopping the copy?
The method of renaming seems to simply judge whether the file is running or occupied, but this method has great drawbacks: when there are many files to be copied, because the file name needs to be restored, the execution efficiency of the code will be relatively low. In the first few versions, I would add "system + read-only" attributes to the backed-up files. In this version, I have canceled this operation. The problem of execution efficiency is also one of the reasons, so for the same reason, I don't plan to add this function. If everyone thinks it is necessary, this function will be added in subsequent versions.
4、
As for illegal characters, it is also very easy to prevent, write a subroutine.
Using code like %data:~0,1% can be done. .
Regarding the prevention of illegal characters, it doesn't seem as simple as you said. For specific reasons, please refer to the analysis of willsort on floor 13 of this post.
5、
楼主, please don't take this as the final code :)
There are still a lot of updates needed :)
Hehe, I'll analyze your code after eating.
Thank you for your patient analysis. More deficiencies need to be discovered by people like you who are patient to test (such as point 3). However, as I said in the update history, if there are no major bugs in this version, I will no longer update the code, because my current energy is somewhat limited, and I can't make more in-depth considerations for irrelevant details.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。