Re: Manipulating textfiles (subtitlefiles for films)
- To: mathgroup at smc.vnet.net
- Subject: [mg57754] Re: Manipulating textfiles (subtitlefiles for films)
- From: dh <dh at metrohm.ch>
- Date: Tue, 7 Jun 2005 05:59:43 -0400 (EDT)
- References: <d7ucvi$ssa$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Peter,
First read the data:
d = Import[FileName];
add e.g. diff=1000:
d = StringReplace[d, RegularExpression[
"{(\\d+)}"] :> ("{" <> ToString[ToExpression["$1"] + diff] <> "}")];
export the changed string:
Export[NewFileName]
sincerely, Daniel
peter W wrote:
> I have a textfile of the following format:
> .
> .
> {822}{918}En del unga människor|tar itu med sina disillusioner
> {926}{1038}genom att söka illusioner på egen hand-
> {1046}{1126}i ett illegalt verkligt virtuellt krigsspel.
> {1134}{1294}Spelets simulerade spänning och dödande|är tvångsmässiga
> och beroendeframkallande.
> {1302}{1430}Några spelare, jobbar|i team som kallas 'parties'.
> {1438}{1550}till och med tjänar sitt leverbröd på spelet.
> .
> .
> It is a subtitle file used to display subtitles in .avi films.
> Sometimes subtitles and the film are not in sync, and the numbers in
> the curly paranthesis has to have a number added or subtracted.
> so, how to add a number to each of the pair of numbers in each line?
> And save the result in a file without changing anything else?
> The numbers in this case is frame numbers I think. (the film may be
> shown with 23 fps for instance.)
> I have tried a couple of variants, and one difficulty is that the
> saved files does not save my special country characters.
>
> Best
> PW
>