我的问题是我做了一个显示目录中所有文件的东西,但因为它太长而且线太多,我决定让它说例如它将暂停的每五行。
较小版本的代码是:
for /r %%a in (*) do echo %%a
所以我猜你有个主意吗?
答案 0 :(得分:0)
为什么不使用为此设计的more命令。它执行的是屏幕而不是5(除非您使用p 5
命令)。
C:\Users\User>more /?
Displays output one screen at a time.
MORE [/E [/C] [/P] [/S] [/Tn] [+n]] < [drive:][path]filename
command-name | MORE [/E [/C] [/P] [/S] [/Tn] [+n]]
MORE /E [/C] [/P] [/S] [/Tn] [+n] [files]
[drive:][path]filename Specifies a file to display one
screen at a time.
command-name Specifies a command whose output
will be displayed.
/E Enable extended features
/C Clear screen before displaying page
/P Expand FormFeed characters
/S Squeeze multiple blank lines into a single line
/Tn Expand tabs to n spaces (default 8)
Switches can be present in the MORE environment
variable.
+n Start displaying the first file at line n
files List of files to be displayed. Files in the list
are separated by blanks.
If extended features are enabled, the following commands
are accepted at the -- More -- prompt:
P n Display next n lines
S n Skip next n lines
F Display next file
Q Quit
= Show line number
? Show help line
<space> Display next page
<ret> Display next line
在for循环使用set /a
和!var中执行此操作!类型变量(阅读所有set&#39; s帮助)。请参阅For /?
和setlocal /?
中的帮助。
答案 1 :(得分:0)
就像@Noodles说MORE
或:
编辑:
@echo off
setlocal enabledelayedexpansion
set /a $C=1
for /r %%a in (*) do (
IF !$C!==5 (
echo.
pause >nul
set /a $C=1)
echo %%a
set /a $C+=1)