Originally, I wanted to communicate with the LZ about the questions raised above (very interesting), but after thinking for a long time, I didn't know how to answer : )
Now I don't even know whether to consider it as purely DOS discussion or the CMD Shell of the XP system that everyone uses...
After I searched most of the LZ's posts in the forum search, I determined that this question is about non-pure DOS issues, haha...
Problem about errorlevel return value~`
Problem about %random% in DOS batch processing
Usage of sc command in DOS batch processing
What does ><nul mean??
A question? By the way, apprenticeship~```
Who can specifically explain the for /f command for me?
Please, expert, help me compile a batch processing for batch-renaming filenames...
……
Seeing that there are problems about <> and for /f reading files and other problems mentioned by the LZ,
Then are these interesting problems supposed to be interesting solutions?
The interesting solution is as follows, it is the way of "writing" itself to read chkdsk and then directly run automatically.
For fun, so it can only run correctly once, haha...
But the LZ's wanted those problem characteristics and redirection and reading files are all used up : )
Also, the LZ may be interested in how not to write redundant carriage return characters at the end... is also used up : )
The following example is only for fun, not practical : )
@for /f %%. in (1.txt) do @set /p=%%.<nul>>"%~f0"
@,
The @, in the last line has a reason, it is to prevent you from directly saving the first line and not giving a line feed,
So, @, is that when encountering the following DOS command can also execute normally,
But this interesting method can only execute normally once~ : D
The "%~f0" used above is the full name of the batch processing's own drive letter path filename, this information can find more messages in the help information of for /? : )
Using Del "%~f0" can also let the batch processing "commit suicide", that is, delete itself~
Self (batch processing itself) writing new information to itself can also be used for special applications such as simple running times or running logs...
The >>"%~f0" used in the above batch processing is appending the output information to cover the target file content's situation to append to the target file content's behind.
And why does "%~f0" want to add %~f0 (that is, batch processing oneself's entire path and other information) with double quotes? It is because if you run where there are spaces (such as desktop),
Then in order to cause the system wrong judgment middle spaces...
For example: CD ABC 123 is not getting into "ABC 123" this directory, to add double quotes the system just knows this is integral,
So the above batch processing oneself information's expression要用 double quotes enclose : )
set /p=%%.<nul is to remove that your 1.txt all took carriage return line feed characters of "c h k d s k",
As for why it can "remove" carriage return and line feed symbols, there is a allusion inside, hee hee...
Need to appreciate the following wonderful article like reading a story:
----------------------------------------------------------------------------------------------------
Brief Analysis of Helpless Signature Code
http://www.cn-dos.net/forum/viewthread.php?tid=18838&fpage=1&highlight=%E7%AD%BE%E5%90%8D
----------------------------------------------------------------------------------------------------
After reading the above article, the LZ can make more interesting things~ : )
(If the friend who hasn't read this article, please put down any thing in hand, go to see "Brief Analysis of Helpless Signature Code" now)
(The most useless is collection, the most useful is to use go to see go to study go to do once to replace the action of collecting uselessly)
[
Last edited by redtek on 2006-11-6 at 10:38 PM ]