일괄 처리 텍스트 내용 가운데 표시 코드

2369 단어
a.txt  
코드:
[Promise don't come easy]
I should have known all along.
There was something wrong.
I just never read between the lines.
Then I woke up one day and found you on your way.
Leaving nothing but my heart behind.
What can I do to make it up to you.
Promises don't come easy.
But tell me if there's a way to bring you back home to stay.
Well I'd promises anything to you.
I've been walkin' around with my head hanging down.
Wondrin' what I'm gonna do.
'Cause when you walked out that door.
CMD 원래 창에서는 윈도우 크기를 조절하지 않고 임시 파일을 생성하지 않으며 텍스트 내용을 가운데에 표시해야 합니다.출력은 다음과 같습니다.
코드:
[Promise don't come easy]
I should have known all along.
There was something wrong.
I just never read between the lines.
Then I woke up one day and found you on your way.
Leaving nothing but my heart behind.
What can I do to make it up to you.
Promises don't come easy.
But tell me if there's a way to bring you back home to stay.
Well I'd promises anything to you.
I've been walkin' around with my head hanging down.
Wondrin' what I'm gonna do.
'Cause when you walked out that door.
Batcher:
sed -e :a -e "s/^.\{1,77\}$/&/;ta"a.txt
sed.exe
http://xiazai.jb51.net/201010/tools/sed_jb51.rar 
batman: 아이디어 설명:
다음 코드는 충분한findstr 명령의 예입니다.findstr/n을 사용하여 줄 번호를 얻어 빈 줄을 호환합니다.
줄 번호를 변수에 값을 부여하기;findstr/o를 사용하여 줄의 문자 편이량을 얻지만,
위쪽, 아래쪽의 문자 편차
두 문자의 편향이 있기 때문에 마지막 줄에 강제로 차를 돌려보내서 원문서를 파괴하지 않는 것을 피할 수 없다
상황에서 임시 파일을 생성할 수밖에 없다.findstr/o를 이용하여 텍스트의 모든 줄의 문자 편향을 한꺼번에 얻을 수 있습니다
이량, 즉 문자 총수인데 효율은 문자별로 판단하는 것보다 훨씬 높을 것이다.
---------------------------------
 
  
@echo off
copy /y 1.txt 2.txt>nul
echo.>>2.txt&echo end>>2.txt
for /f "tokens=1,2* delims=: " %%i in ('findstr /n /o .* 2.txt') do (
set "_%%i=%%j"&set ".%%i=%%k"
  if %%i geq 2 call :lp %%i
)
del /q 2.txt&pause>nul&goto :eof
:lp
set /a n=%1-1
set /a num=_%1-_%n%-2
set /a kl=(80-num)/2
for /l %%i in (1,1,%kl%) do set /p= call,set /p=%%.%n%%%

좋은 웹페이지 즐겨찾기