@echo off
cls
Color 0A
:Read
setlocal EnableDelayedExpansion
set file=WinSCP-5.11.2-ReadMe.txt
call :ReadInLines
call :EchoLines
echo insert other code here
pause
endlocal
(goto) 2>nul
:ReadInLines
set Counter=0
for /f "DELIMS=" %%i in ('type %file%') do (
set /a Counter+=1
title Lines In File: !Counter!
set "Line_!Counter!=%%i"
)
(goto) 2>nul
:EchoLines
For /L %%C in (1,1,%Counter%) Do (echo %%C. !Line_%%C!)
pause
所以这是我此刻的需要从线在批处理文件中读取到B线
它能够成功地读取并输入该文件的整个代码,但我想在工作不需要滚动(更大的文件)
基本上我需要能够做的方法是阅读一定量线
例如:
读1-8行也读5至13行
基本上我需要能够互换它读取到的数字,一个标签,以便调优选
完成代码:
call.bat:
@echo off
cls
Color 0A
:: double call
call text-read-lines-alt.bat 1 8
call text-read-lines-alt.bat 9 20
pause
:: multiselect (a) (b) (a) (b) etc...
call text-read-lines-alt.bat 1 20 23 29
pause
:: call then calling outside text range (outputs first but not second)
call text-read-lines-alt.bat 1 8
call text-read-lines-alt.bat 80 100
pause
:: another call outside text range (outputs nothing)
call text-read-lines-alt.bat 90 100
pause
文本的读线-alt.bat:
@echo off
setlocal EnableDelayedExpansion
set file=WinSCP-5.11.2-ReadMe.txt
SET "parms=%*"
call :ReadInLines
call :EchoLines
echo insert other code here
endlocal
(goto) 2>nul
:ReadInLines
set Counter=0
for /f "DELIMS=" %%i in ('type %file%') do (
set /a Counter+=1
title Lines In File: !Counter!
CALL :gate !counter!
IF DEFINED RECORD set "Line_!Counter!=%%i"
)
(goto) 2>nul
:EchoLines
For /L %%C in (1,1,%Counter%) Do IF DEFINED line_%%C (echo %%C. !Line_%%C!)
GOTO :EOF
:gate
SET "record="
IF NOT DEFINED parms GOTO :EOF
FOR /f "tokens=1,2*" %%x IN ("%parms%") DO (
IF %1 gtr %%y SET "parms=%%z"&GOTO gate
IF %1 geq %%x SET "record=Y"
)
GOTO :EOF
和这里是所有的辛勤工作去了到:http://old-school-gamer.tk/batch/text-reader/releases/ :D
花了我一段时间来弄清楚xD的这个blob,但好吧,所以基本上我会做一些事情例如: call text-read-lines-alt.bat 1 20 这将在输出中产生第1到第20行。 我可以很容易地添加一个部分,说如果它在文件末尾停止输出:D 有一件事我没有得到的是%% Z部分。这是必要的吗? afaik这是一个多选的权利?我可以这样使用: call text-read-lines-alt.bat 1 20 23 25 哪会产生1-20和23-25 是吗? – Ushida
好让没有做什么我想它做: http://prntscr.com/gybcbl 但是......它工作正常,如果需要 谢谢你,我可以只调用批处理文件两次:d 你想让我把你作为一个学分吗? – Ushida
也调用它一次为1-8和再次为9-20产生成功,但也产生1-12? 东西关闭,我不能告诉什么 – Ushida