I want every 2 lines to have specific text added at the end of each of them.
-
for example lets say i have the following text
line1 line2 line3 line4 line5 line6
I want this text to become
line1.mp4 line2.srt line3.mp4 line4.srt line5.mp4 line6.srt
ive searched for a bit and couldnt fine a solution to do this specifically, thanks
-
@GabrielP said in I want every 2 lines to have specific text added at the end of each of them.:
ive searched for a bit and couldnt fine a solution to do this specifically
Specifically, no, because no one has your exact text. Expecting any search on the internet to give you exactly what you want without you having to interpret it for your specific circumstance is a bit optoomuchstic.
But this is the kind of situation that the REPLACE FROM A SMALL LIST OF VALUES section of our FAQ was meant to cover: in general, it shows you how to replace matched text with a small list of values. In your specific situation, you would want to search for
$
(match at the end of the line, so the replacement is just appended without deleting anything), and your list of replacements would be['.mp4', '.srt']
. -
@GabrielP I would use a search/replace for lines ending with odd/even values. It’s low tech but is safe and works in a predictable and understandable way.
Search:
([02468])$
Replace:\1.srt
and
Search:([13579])$
Replace:\1.mp4
The above makes the assumption that your data has numbers at the ends of them. If your actual data is more like.
safe and works in a predictable and understandable way
then I still like do do it in several safe passes. For example - this will join pairs of lines using
~
as the separator.
Search:^(.+)\R(.+)$
Replace:\1~\2
I do a search/replace all and see that the results look good. The last line is just the wordway
meaning it’s not part of a pair. With real data I would think about how that should be dealt with but for now, I don’t care.Once the data looks safe it’s easy to then
Search:$
Replace:.srt
and
Search:~
Replace:.mp4\r\n
The
~
can be any character as long as it’s something that is not used in your file. You can use anything such as\t
tab,\x00
NUL, etc. -
@PeterJones is there no way to add text to odd lines and then another text to even lines?
right now im trying this,
(?-s)^(.+\R)(.+\R?)
\1.mp4 & \2.srtbut unfortunately my text goes from this
(im replacing ONLY the first 2 lines btw, to show you that it ends up affecting the 3rd line too)1 - Aula de apresentação 1 - Aula de apresentação 1 - Políticas Públicas: Definições e Componentes 1 - Políticas Públicas: Definições e Componentes
to this
1 - Aula de apresentação .mp4 & 1 - Aula de apresentação .srt1 - Políticas Públicas: Definições e Componentes 1 - Políticas Públicas: Definições e Componentes
when if im only replacing the first 2 lines, it just want it to become this
1 - Aula de apresentação.mp4 1 - Aula de apresentação.srt 1 - Políticas Públicas: Definições e Componentes 1 - Políticas Públicas: Definições e Componentes
-
@mkupper this worked great, thanks!
-
This post is deleted!