China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-10 07:55
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Solved Help, how to use a batch file to transform a text file into the following format View 787 Replies 10
Original Poster Posted 2008-11-08 17:58 ·  中国 山东 青岛 联通
初级用户
★★
Credits 107
Posts 60
Joined 2007-11-07 22:03
18-year member
UID 102010
Gender Male
Status Offline
There are two documents

The first one is as follows:
Title: The Million Pound Note
Once upon a time when Britain was very rich There was once a time when Britain was very rich
deep in the box of bank in England in the huge vault of the Bank of England
there was more gold than anywhere in the world more gold was stored there than anywhere else in the world

The second one:
00:22.36 --> 01:16.16 Title: The Million Pound Note
01:16.16 --> 01:19.48 Once upon a time when Britain was very rich There was once a time when Britain was very rich


In the second document, the number after the arrow is the number from the next line


How can I convert it?

I'm a newbie, please enlighten me, experts!Solved

[ Last edited by kaikai163 on 2008-11-8 at 23:12 ]
Floor 2 Posted 2008-11-08 18:13 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
In the second document, the number after the arrow is the number from the second line

What do you mean?
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
kaikai163 +1 2008-11-08 22:24
Floor 3 Posted 2008-11-08 18:39 ·  中国 山东 淄博 联通
银牌会员
★★★
Credits 1,604
Posts 646
Joined 2008-04-13 23:39
18-year member
UID 115804
Gender Male
Status Offline
@echo off & setlocal enabledelayedexpansion
for /f "tokens=1* delims=" %%a in (a.txt) do (
set /a n+=1,m=n-1
set ".!n!=%%a" & set "_!n!=%%b"
if !n! gtr 1 call :loop "%%a"
)

pause>nul & exit /b

:loop
echo !.%m%! --^> %~1 !_%m%!


Also, the OP didn't explain clearly how the last line should be displayed...
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
kaikai163 +2 2008-11-08 22:25
心绪平和,眼藏静谧,无比安稳的火... Purification of soul...Just a false...^_^
Floor 4 Posted 2008-11-08 18:42 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Subtitle file processing...
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore
Floor 5 Posted 2008-11-08 22:23 ·  中国 山东 青岛 联通
初级用户
★★
Credits 107
Posts 60
Joined 2007-11-07 22:03
18-year member
UID 102010
Gender Male
Status Offline
The poster in reply #4 is a real expert! That's exactly what I need!

But now I've found a piece of software that can convert it, that is, convert lrc to srt, but there are quite a few blank lines in it

It looks like this

4
00:01:19,489 --> 00:01:21,480
deep in the box of bank in England in the huge vault of the Bank of England

5
00:01:21,489 --> 00:01:27,160
there was more gold than anywhere in the world more gold was stored there than anywhere else in the world

6
00:01:27,169 --> 00:01:27,720
safe the banks of England. back then, reputable people often said


How can I remove the numbers and blank lines, and put the subtitles and time on one line??

Still asking all you experts to kindly give me some advice!
Floor 6 Posted 2008-11-08 22:27 ·  中国 山东 青岛 联通
初级用户
★★
Credits 107
Posts 60
Joined 2007-11-07 22:03
18-year member
UID 102010
Gender Male
Status Offline
Dizzy... by not paying attention I gave points to reply #2, I originally wanted to give them to the big brother in reply #3!
Floor 7 Posted 2008-11-08 22:32 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Floor 8 Posted 2008-11-08 22:59 ·  中国 山东 青岛 联通
初级用户
★★
Credits 107
Posts 60
Joined 2007-11-07 22:03
18-year member
UID 102010
Gender Male
Status Offline
Moderator, you're practically a god, I admire you so much!

But I still have one tiny little request

00:02:21,169 --> 00:02:23,120 A bet is for making a bet

00:02:23,129 --> 00:02:26,240 Making a bet, you mean making a bet


Moderator, can you tell why the space before “A bet is for making a bet” on the first line is so wide?

Then please modify your batch file a bit so that the second line also has a space like that added in front of it.

Sorry to trouble you!
Floor 9 Posted 2008-11-08 23:02 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
In the code in reply #7, change this yourself:
set line=!line! %%i
Try replacing the space between !line! and %%i with a tab
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
kaikai163 +2 2008-11-08 23:10
Floor 10 Posted 2008-11-08 23:03 ·  中国 山东 青岛 联通
初级用户
★★
Credits 107
Posts 60
Joined 2007-11-07 22:03
18-year member
UID 102010
Gender Male
Status Offline
Originally posted by HAT at 2008-11-8 11:02 PM:
In the code in reply #7, change this yourself:
set line=!line! %%i
Try replacing the space between !line! and %%i with a tab


Okay, I'll try it!
Floor 11 Posted 2008-11-08 23:11 ·  中国 山东 青岛 联通
初级用户
★★
Credits 107
Posts 60
Joined 2007-11-07 22:03
18-year member
UID 102010
Gender Male
Status Offline
Success, thanks moderator HAT!
Forum Jump: