Computing.Net > Forums > Programming > nt batch to replace string in srt file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

nt batch to replace string in srt file

Reply to Message Icon

Name: imrsi25
Date: June 2, 2009 at 00:11:21 Pacific
OS: Windows XP PRO SP3
CPU/Ram: 1,60 GHz/1,49 GB
Product: Lenovo / C200
Subcategory: Batch
Comment:

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.




Response Number 1
Name: reno
Date: June 2, 2009 at 00:39:37 Pacific
+1
Reply:

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.



Response Number 2
Name: imrsi25
Date: June 2, 2009 at 05:37:11 Pacific
+1
Reply:

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?



Response Number 3
Name: ghostdog
Date: June 2, 2009 at 07:20:25 Pacific
+1
Reply:

check your tone. you are asking for help here. the beggar cannot be the chooser.



Response Number 4
Name: reno
Date: June 2, 2009 at 08:22:36 Pacific
+1
Reply:

you know why, because you are so f****** dumb to implement my suggestion into a working script.



Response Number 5
Name: imrsi25
Date: June 2, 2009 at 09:05:54 Pacific
+1
Reply:

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!



Related Posts

See More



Response Number 6
Name: reno
Date: June 2, 2009 at 10:53:58 Pacific
+1
Reply:

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.



Response Number 7
Name: imrsi25
Date: June 2, 2009 at 12:51:00 Pacific
+1
Reply:

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.
===================================================



Response Number 8
Name: reno
Date: June 2, 2009 at 23:11:03 Pacific
+1
Reply:

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.



Response Number 9
Name: imrsi25
Date: June 2, 2009 at 23:51:32 Pacific
+1
Reply:

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.



Reply to Message Icon

vbs/html yahoo finance st... batch to move files with ...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Google Ads



Results for: nt batch to replace string in srt file

find and replace string in a file www.computing.net/answers/programming/find-and-replace-string-in-a-file/19987.html

Batch to replace text in text file www.computing.net/answers/programming/batch-to-replace-text-in-text-file/19166.html

Batch file to replace text in file www.computing.net/answers/programming/batch-file-to-replace-text-in-file/20070.html