简体   繁体   中英

Windows Command Prompt - For statement & Loops

I have two problems.

First: Not all txt files will open at once. One file will open for viewing then I will close it and then the next in line of the directory will open and so on an so forth until all files have been processed. How do i get all files to open without having to close previous txt file?

Second: The variable count never counts up. It continuously echos 1. How do i get it to count up? I'm trying to get the count to echo out how many txt files where opened within directory.

set /A Count=0
for %%I in (*.txt) do set /A Count=%Count%+1
echo %Count%

for %%I in (*.txt) do set /A Count=Count+1&"%%I"

%count% is the parse-time value of count - when the line was parsed, not the run-time value (see articles about delayed expansion using the search facility in the top bar).

The set /a syntax allows variables to be named "nude" to access the run-time value.

Another method would be

set /a count+=1

The open file facility is missing from your code. "%%I" should open the file using your default editor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM