早教吧作业答案频道 -->其他-->
如何通过bat批处理实现这样的文本样式转换?一个文本文件内容包括很多段落。想通过bat批处理在这个文本文件每段的第一行前面加上“A:”,其他行前面加上“B:”。具体样式如下:文
题目详情
如何通过bat批处理实现这样的文本样式转换?
一个文本文件内容包括很多段落。想通过bat批处理在这个文本文件每段的第一行前面加上“A:”,其他行前面加上“B:”。具体样式如下:
文本文件原样式是:
able
[having the power to do something]
Are you able to speak English?
about
[(1) almost; (2) of or having a relation to]
He completed about half of his work. (1)
We talk about the weather. (2)
above
[at a higher place]
His head was above the water.
…………
转换后的文本文件样式是:
A:able
B:[having the power to do something]
B:Are you able to speak English?
A:about
B:[(1) almost; (2) of or having a relation to]
B:He completed about half of his work. (1)
B:We talk about the weather. (2)
A:above
B:[at a higher place]
B:His head was above the water.
…………
一个文本文件内容包括很多段落。想通过bat批处理在这个文本文件每段的第一行前面加上“A:”,其他行前面加上“B:”。具体样式如下:
文本文件原样式是:
able
[having the power to do something]
Are you able to speak English?
about
[(1) almost; (2) of or having a relation to]
He completed about half of his work. (1)
We talk about the weather. (2)
above
[at a higher place]
His head was above the water.
…………
转换后的文本文件样式是:
A:able
B:[having the power to do something]
B:Are you able to speak English?
A:about
B:[(1) almost; (2) of or having a relation to]
B:He completed about half of his work. (1)
B:We talk about the weather. (2)
A:above
B:[at a higher place]
B:His head was above the water.
…………
▼优质解答
答案和解析
Can't understand why not use VBS, it will be much easier! Well, it's interesting to do this using CMD. The following is a possible solution.
REM --------START--------
@ECHO OFF
IF "%~1"=="" GOTO :EOF
ECHO 请稍后. . .
CD /D "%~dp1"
ECHO.>YOU_YOU
TYPE "%~1">>YOU_YOU
SET newName="%~n1_yy%~x1"
FINDSTR /N /V /R /C:"^[ ]*$" YOU_YOU>%newName%
SET /A n=1
SETLOCAL EnableDelayedExpansion
(FOR /F "usebackq delims=: tokens=1*" %%I IN (%newName%) DO (
IF %%I==!n! (ECHO B:%%J) ELSE (
SET /A d=%%I-n
FOR /L %%K IN (1,1,!d!) DO ECHO.
ECHO A:%%J)
SET /A n=%%I+1))>YOU_YOU
MORE +1%newName%
DEL /Q YOU_YOU
START "" %newName%
REM --------END--------
Save above codes in a batch file, for example, "section.bat". You can put this file anywhere. If you wanna change some text file, DRAG it onto the icon of "section.bat", then everything will be done. Please Hi me if any problem!
REM --------START--------
@ECHO OFF
IF "%~1"=="" GOTO :EOF
ECHO 请稍后. . .
CD /D "%~dp1"
ECHO.>YOU_YOU
TYPE "%~1">>YOU_YOU
SET newName="%~n1_yy%~x1"
FINDSTR /N /V /R /C:"^[ ]*$" YOU_YOU>%newName%
SET /A n=1
SETLOCAL EnableDelayedExpansion
(FOR /F "usebackq delims=: tokens=1*" %%I IN (%newName%) DO (
IF %%I==!n! (ECHO B:%%J) ELSE (
SET /A d=%%I-n
FOR /L %%K IN (1,1,!d!) DO ECHO.
ECHO A:%%J)
SET /A n=%%I+1))>YOU_YOU
MORE +1
DEL /Q YOU_YOU
START "" %newName%
REM --------END--------
Save above codes in a batch file, for example, "section.bat". You can put this file anywhere. If you wanna change some text file, DRAG it onto the icon of "section.bat", then everything will be done. Please Hi me if any problem!
看了如何通过bat批处理实现这样的...的网友还看了以下:
小六数学附加题甲、乙两车分别从A、B两地同时出发,相向而行,经过若干小时相遇.相遇后,按原速继续前进 2020-03-30 …
一道关于行程问题的奥数题两条公路成十字交叉.甲从十字路口南1350米处向北直行,乙从十字路口处向东 2020-05-13 …
甲乙两辆汽车同时从相距420千米的A.B两地相向而行,经过6小时相遇甲、乙两辆汽车同时从相距420 2020-06-14 …
英语翻译31、过①行过夷门,见侯生.《信陵君窃符救赵》②一出门,裘马过世家焉.《促织》③花过而采, 2020-06-25 …
“对溶液进行过过滤、洗涤、和蒸馏”这句话用英文怎么说,一个句子中是不是不能同时出现多个动词? 2020-06-29 …
“我这一辈子走过许多地方的路,行过许多地方的桥……”出自哪里?“我这一辈子走过许多地方的路,行过许 2020-07-07 …
人急行的速度大约是2m/s,人急行横过6m宽的马路需要的时间大约是多少秒?人急行的速度大约是2m/ 2020-07-20 …
图是滑雪运动员在雪地滑行的情景.在滑行过程中,如果以滑板为参照物,运动员是的.滑板和雪面摩擦生热,是 2020-10-30 …
古文翻译、会的来(一)、素简贵,不私事上官。(二)、未尝有所造诣,所之唯至田舍及庐山游观而已。(三) 2020-11-26 …
对下列文言句意的理解,不正确的一项是()A.君子博学而日参省乎己,则知明而行无过矣.理君子广泛地学习 2020-11-26 …