Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
932 views
in Technique[技术] by (71.8m points)

cmd - How to read and print contents of text file line by line?

So, I have no clue on how to have CMD echo lines from a *.txt text file one at a time with a tiny delay to make it seem like it's processing.

Is this even possible with a batch alone?

I've tried doing research, but I can't find sufficient text manipulation to be able to do this, but I do know how to make a pause between each command and how to do loops.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Despite your question being off topic, I have decided to include this because, there are already two answers and it can be achieved using a single line.

From a batch file:

@For /F Tokens^=1*Delims^=]^ EOL^= %%A In ('Find /N /V ""^<"C:est.txt"') Do @Echo(%%B&>Nul PathPing 127.0.0.1 -n -q 1 -p 450

From the Command Prompt:

For /F Tokens^=1*Delims^=]^ EOL^= %A In ('Find /N /V ""^<"C:est.txt"') Do @Echo(%B&>Nul PathPing 127.0.0.1 -n -q 1 -p 1350

Both examples do not omit empty lines from your source file, C:est.txt, which can be changed as required.
I have used PathPing for the 'tiny delay', because it seems more controllable; to adjust the delay all you need to do is change the last number until you find your most pleasing output.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...