nt batch to replace string in srt file

June 2, 2009 at 00:11:21
Specs: Windows XP PRO SP3, 1,60 GHz/1,49 GB
I'd like to replace string with new one in *.srt file.
I found similar solution created by M2 here:

http://www.computing.net/answers/pr...
----------------------------------------------------
@echo off > newfile
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (oldfile) do (
set str=%%a
set str=!str:oldtext=newtext!
echo !str! >> newfile
)
-----------------------------------------------------
Is it possible:
1. to make upper solution case sensitive,
2. to read from file a list of strings which need to be replaced at once,
instead of replaceing strings one by one, and
3. in case that in "oldfile" exist more than one same string, just to find the first and replace with new one (the others except the first one have to be left unchanged).

Thanks in advance.


See More: nt batch to replace string in srt file

Report •


#1
June 2, 2009 at 00:39:37
1. yes, i think it's possible using find.exe, but it will impact on the performance severely when replacing string in large file.

2. use for loop in list of strings
eg.
set list=this is a list of strings
for /f "tokens=*" %%a in (file.txt) do (
set str=%%a
for %%b in (%list%) do set str=!str:%%b=!
)

3. use goto:breakAloop when match found

i would suggest using vbscript that support case sensitive replace function.
vbBinaryCompare 0 Perform a binary comparison.
vbTextCompare 1 Perform a textual comparison.


Report •

#2
June 2, 2009 at 05:37:11
First off all, my apology about my voute in which I said that your answer is the best, the corect is that it is the worst answer I've ever got!
Everyting in your answer is wrong!!!
Why are you dealing with something that you understand less than me?

Report •

#3
June 2, 2009 at 07:20:25
check your tone. you are asking for help here. the beggar cannot be the chooser.

Report •

Related Solutions

#4
June 2, 2009 at 08:22:36
you know why, because you are so f****** dumb to implement my suggestion into a working script.

Report •

#5
June 2, 2009 at 09:05:54
I am asking for help only those people who can help.
I don't need so-called help. If you can help, then help, but don't take with your "suggestions" place those pearsons who can know to give real answer.
So if I ask: "Is it possible to make upper solution case sensitive?", do you think that your answer: "Yes, i think it's possible using find.exe..." is really what I expected?
Maybe, here is someone really f**... d**..., but I'm absolutely sure that guy is not me!

Report •

#6
June 2, 2009 at 10:53:58
think carefully, the dumb guy is you.
if you had reply nicely, i'll write and show you the whole working script either in batch or vbs.

oops, or you brain is too dumb to think.


Report •

#7
June 2, 2009 at 12:51:00
It is obviously that this is left out of the normal communication.
You're very conceited pearson who hardly tolerate criticism.
Think, If I ask someone a piece of bread, and he tells me that I
can buy it in the bakery, can we say that he helped me?
I think, he not!
Or maybe you really think that I do not know where to buy a bread?

I know exactly what, but I do not know how, because my knowledge in programming is very poor and that is the main reason why I need help.
===================================================
Now, I think that is enough of this kind of conversation.
I do this all for hobbies and fun, and this certainly is not more fun.
===================================================


Report •

#8
June 2, 2009 at 23:11:03
First off all, my apology about my voute in which I said that your answer is the best, the corect is that it is the worst answer I've ever got!
Everyting in your answer is wrong!!!
Why are you dealing with something that you understand less than me?

this ain't criticism, remember, me and the others are here to help on voluntary basis. i perfectly know what i am suggesting and how to implement it.

I know exactly what, but I do not know how, because my knowledge in programming is very poor and that is the main reason why I need help.
then DON'T be such a cocky a*** h*** when asking for help.

Now, I think that is enough of this kind of conversation.
I do this all for hobbies and fun, and this certainly is not more fun.

if you can't stand it, then DO NOT start mental harashment in the first place. and think again the consequenses before you speak.


Report •

#9
June 2, 2009 at 23:51:32
I almost forgot, have you seen that movie, "Dumb & Dumber"
if you didn't - look at it, if you're - look at it again!
Maybe looking at that film will help you to calm down.
Keeping your nerves down, will help you to live longer.

Report •


Ask Question