校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識(shí)庫 > 批處理提取不同行上的內(nèi)容的代碼

批處理提取不同行上的內(nèi)容的代碼

熱門標(biāo)簽:用電話機(jī)器人取代人工 外呼獲客系統(tǒng) 沈陽電銷 aa專業(yè)電話外呼系統(tǒng) 浙江語音外呼系統(tǒng)招商 谷歌地圖標(biāo)注錯(cuò)位 四川防封電銷卡套餐 95專業(yè)外呼線路是怎么回事 無錫極信防封電銷卡價(jià)格
for instance:-

for /f "delims=" %%a in (input.txt) do ...

for /f "delims=" %%a in ('type input.txt') do ...

for /f "delims=" %%a in ('more ^ input.txt') do ...

However, only the last method (using the more command) will give consistent results across Windows NT, 2000, XP and 2003. The first method does not recognise unicode files. Also, the usebackq switch must be used if the input filename contains spaces. The second method, using the type command, also fails to recognise unicode files on Windows 2000, XP and 2003 if the input file does not begin with a bit order mark (BOM).

In all the examples, assume the contents of of the file numbers.txt to be:-

one
two
three
four
five
six
seven
eight
nine
ten

Displaying the first line

This example prints one.

@echo off setlocal ENABLEEXTENSIONS
set "first="
for /f "delims=" %%a in ('more ^ numbers.txt') do (
if not defined first set first=%%a
)
echo/%first%

Displaying the first X lines

This example prints one, two and three.

@echo off setlocal ENABLEEXTENSIONS
set "lines=3"
set i=-1
set "ok="
for /f "delims=" %%a in ('more ^ numbers.txt') do (
set/a i+=1 for /f %%z in ('echo/%%i%%') do (
if "%%z"=="%lines%" set ok=1
)
if not defined ok echo/%%a
)

Displaying the last line

This example prints ten.

@echo off setlocal ENABLEEXTENSIONS
for /f "delims=" %%a in ('more ^ numbers.txt') do set "last=%%a"
echo/%last%

Displaying the last X lines

This example prints nine and ten.

@echo off setlocal ENABLEEXTENSIONS
set "lines=2"
for /f %%a in ('find/c /v "" ^ numbers.txt') do set/a skip=%%a-lines
for /f "delims=" %%a in ('more/e +%skip% ^ numbers.txt') do (
echo/%%a
)

Displaying the Nth line

This example prints three. Note that instead of using the more command's /e switch, the skip option could have been used with the for /f command, however, this fails is it is set to any number less than one.

@echo off setlocal ENABLEEXTENSIONS
set LineNo=3
set "line="
set/a LineNo-=1
for /f "delims=" %%a in ('more/e +%LineNo% ^ numbers.txt') do (
if not defined line set "line=%%a"
)
echo/%line%

Displaying the Nth line plus X number of lines

This example prints five and six.

@echo off setlocal ENABLEEXTENSIONS
set start=5
set "lines=2"
set/a i=-1,start-=1
set "ok="
for /f "delims=" %%a in ('more/e +%start% ^ numbers.txt') do (
set/a i+=1 for /f %%z in ('echo/%%i%%') do (
if "%%z"=="%lines%" set ok=1
)
if not defined ok echo/%%a
)

標(biāo)簽:煙臺(tái) 廣安 青島 常德 迪慶 興安盟 連云港 南平

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《批處理提取不同行上的內(nèi)容的代碼》,本文關(guān)鍵詞  批處理,提取,不同,行上,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《批處理提取不同行上的內(nèi)容的代碼》相關(guān)的同類信息!
  • 本頁收集關(guān)于批處理提取不同行上的內(nèi)容的代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 会泽县| 罗江县| 齐齐哈尔市| 湘西| 上犹县| 达尔| 广南县| 林周县| 河池市| 仲巴县| 桃园县| 当阳市| 金坛市| 梁山县| 中西区| 天镇县| 墨竹工卡县| 永丰县| 黄山市| 宁国市| 南澳县| 宁武县| 襄樊市| 商河县| 常德市| 齐齐哈尔市| 柳州市| 余干县| 平阳县| 德保县| 大庆市| 禄丰县| 海宁市| 苗栗县| 沧州市| 绥滨县| 达尔| 应用必备| 滦平县| 梅河口市| 汉川市|