VBScript to compare each line of string to each line of text file and make replacementsIterating each character in a string using PythonFind and replace string in my text with VBScriptVBScript variable loses its content?vbscript text file search a line with multiple stringsVbscript help-read a text file line by line and populate contents of each line in an excel and search and count for a repeating stringVBscript replaces text but adds blank linecomparing 2 files in vbscripthow to replace text in vbscriptFacing issue in replace string in a file using vbscriptvbscript replacing text without overwriting in a text file
Are there any German nonsense poems (Jabberwocky)?
Split into three!
Fill area of x^2+y^2>1 and x^2+y^2>4 using patterns and tikzpicture
EU rights when flight delayed so much that return is missed
How to find sum of maximum K elements in range in array
Why does Bran want to find Drogon?
Is superuser the same as root?
How to create a `range`-like iterable object of floats?
What could be my risk mitigation strategies if my client wants to contract UAT?
Why did other houses not demand this?
Testing using real data of the customer
Prince of Darkness goes cryptic
How to teach an undergraduate course without having taken that course formally before?
Why A=2 and B=1 in the call signs for Spirit and Opportunity?
Status of proof by contradiction and excluded middle throughout the history of mathematics?
If I arrive in the UK, and then head to mainland Europe, does my Schengen visa 90 day limit start when I arrived in the UK, or mainland Europe?
Complications of displaced core material?
Did "hundreds of birds" fall out of the sky in the Netherlands due to a 5G test?
Is it safe to redirect stdout and stderr to the same file without file descriptor copies?
Why is 'additive' EQ more difficult to use than 'subtractive'?
I want to ask company flying me out for office tour if I can bring my fiance
"Official wife" or "Formal wife"?
Why do testers need root cause analysis?
Is it normal to "extract a paper" from a master thesis?
VBScript to compare each line of string to each line of text file and make replacements
Iterating each character in a string using PythonFind and replace string in my text with VBScriptVBScript variable loses its content?vbscript text file search a line with multiple stringsVbscript help-read a text file line by line and populate contents of each line in an excel and search and count for a repeating stringVBscript replaces text but adds blank linecomparing 2 files in vbscripthow to replace text in vbscriptFacing issue in replace string in a file using vbscriptvbscript replacing text without overwriting in a text file
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm making a little .srt translator tool that will scrape each text line of a .srt file, translate via google translate, and make the replacements into a new file. I've got everything done except for make the actual replacements. Seems like it should be easy, but I'm struggling with the iteration.
Here's my code:
Set IE = CreateObject("internetexplorer.application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
SourceCaptionFile = objFSO.GetParentFolderName(WScript.ScriptFullName) & "captions.srt"
OutputCaptionFile = objFSO.GetParentFolderName(WScript.ScriptFullName) & "NEW_captions.srt"
on error resume next
langURL_es = "https://translate.google.com/#view=home&op=translate&sl=en&tl=es"
'============================================================
Set objFile = objFSO.OpenTextFile(SourceCaptionFile, 1, true) 'for reading
Do until objFile.AtEndOfStream
if instr(objFile.Readline,">") then
capText = capText & objFile.ReadLine & vbcrlf
end if
loop
objFile.Close
'============================================================
'Navigate to translator and get translations
IE.Visible = true
IE.Navigate langURL_es
Do While IE.Busy or IE.ReadyState <> 4: WScript.sleep 100: Loop
Do Until IE.Document.ReadyState = "complete": WScript.sleep 100: Loop
wscript.sleep 1000
capline = split(capText,vbcrlf)
for i = 0 to ubound(capline)
ie.document.getelementbyid("source").innertext = capline(i)
Do While IE.Busy or IE.ReadyState <> 4: WScript.sleep 100: Loop
Do Until IE.Document.ReadyState = "complete": WScript.sleep 100: Loop
for each div in ie.document.getelementsbytagname("div")
if div.getAttribute("class") = "result-shield-container tlid-copy-target" then
captrans = captrans & capline(i-1) & "," & div.innertext & vbcrlf
end if
next
next
'============================================================
'**************THIS IS THE SECTION THAT'S NOT WORKING RIGHT**************
'compare translations against captions.srt file and make replacements
Set objFile = objFSO.OpenTextFile(SourceCaptionFile, 1, true) 'for reading
splitfile = split(objfile.readall,vbcrlf)
for each a in splitfile
arrCaptrans = split(captrans,",")
for i = 0 to ubound(arrCaptrans)
if a = arrCaptrans(i) then
newline = newline & arrCaptrans(i+1) & vbcrlf
else
newline = newline & a & vbcrlf
end if
next
next
objFile.Close
wscript.echo newline
'============================================================
'Write translated file
Set objTransFile = objFSO.OpenTextFile(OutputCaptionFile, 2, true) 'for writing
objTransFile.write newline
objTransFile.Close
'============================================================
wscript.echo "Done"
Here is the output I'm expecting:
1
00: 00: 06,800 -> 00: 00: 11,040
-¡Tenemos que averiguar cómo abrir esto!
2
00: 00: 11,080 -> 00: 00: 13,040
-¿Qué haces con ese nickel?
3
00: 00: 13,160 -> 00: 00: 20,440
-Por eso necesitamos sacar el dinero del chocolate de aquí.
4
00: 00: 20,440 -> 00: 00: 22,080
-No hay chocolate dentro de eso.
5
00: 00: 22,580 -> 00: 00: 23,960
-Sí hay
Here is the contents of my source "captions.srt" file:
1
00:00:06,800 --> 00:00:11,040
-We have to figure out how to open this!
2
00:00:11,080 --> 00:00:13,040
-What are you doing with that nickel?
3
00:00:13,160 --> 00:00:20,440
-That's why we need to get the chocolate money out of here
4
00:00:20,440 --> 00:00:22,080
-There's no chocolate inside that.
5
00:00:22,580 --> 00:00:23,960
-Yes there is
*EDIT:
I'm trying to compare each line of the source .srt file with the string I named "captrans". "captrans" contains rows of "sourcetext,translatedtext". I'm splitting on commas, reading each line of source file and if source file line matches (before comma) captrans then replace with (after comma) captrans. Hope this makes sense...
Thank you for any help you can provide!
web-scraping vbscript iteration writefile
add a comment |
I'm making a little .srt translator tool that will scrape each text line of a .srt file, translate via google translate, and make the replacements into a new file. I've got everything done except for make the actual replacements. Seems like it should be easy, but I'm struggling with the iteration.
Here's my code:
Set IE = CreateObject("internetexplorer.application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
SourceCaptionFile = objFSO.GetParentFolderName(WScript.ScriptFullName) & "captions.srt"
OutputCaptionFile = objFSO.GetParentFolderName(WScript.ScriptFullName) & "NEW_captions.srt"
on error resume next
langURL_es = "https://translate.google.com/#view=home&op=translate&sl=en&tl=es"
'============================================================
Set objFile = objFSO.OpenTextFile(SourceCaptionFile, 1, true) 'for reading
Do until objFile.AtEndOfStream
if instr(objFile.Readline,">") then
capText = capText & objFile.ReadLine & vbcrlf
end if
loop
objFile.Close
'============================================================
'Navigate to translator and get translations
IE.Visible = true
IE.Navigate langURL_es
Do While IE.Busy or IE.ReadyState <> 4: WScript.sleep 100: Loop
Do Until IE.Document.ReadyState = "complete": WScript.sleep 100: Loop
wscript.sleep 1000
capline = split(capText,vbcrlf)
for i = 0 to ubound(capline)
ie.document.getelementbyid("source").innertext = capline(i)
Do While IE.Busy or IE.ReadyState <> 4: WScript.sleep 100: Loop
Do Until IE.Document.ReadyState = "complete": WScript.sleep 100: Loop
for each div in ie.document.getelementsbytagname("div")
if div.getAttribute("class") = "result-shield-container tlid-copy-target" then
captrans = captrans & capline(i-1) & "," & div.innertext & vbcrlf
end if
next
next
'============================================================
'**************THIS IS THE SECTION THAT'S NOT WORKING RIGHT**************
'compare translations against captions.srt file and make replacements
Set objFile = objFSO.OpenTextFile(SourceCaptionFile, 1, true) 'for reading
splitfile = split(objfile.readall,vbcrlf)
for each a in splitfile
arrCaptrans = split(captrans,",")
for i = 0 to ubound(arrCaptrans)
if a = arrCaptrans(i) then
newline = newline & arrCaptrans(i+1) & vbcrlf
else
newline = newline & a & vbcrlf
end if
next
next
objFile.Close
wscript.echo newline
'============================================================
'Write translated file
Set objTransFile = objFSO.OpenTextFile(OutputCaptionFile, 2, true) 'for writing
objTransFile.write newline
objTransFile.Close
'============================================================
wscript.echo "Done"
Here is the output I'm expecting:
1
00: 00: 06,800 -> 00: 00: 11,040
-¡Tenemos que averiguar cómo abrir esto!
2
00: 00: 11,080 -> 00: 00: 13,040
-¿Qué haces con ese nickel?
3
00: 00: 13,160 -> 00: 00: 20,440
-Por eso necesitamos sacar el dinero del chocolate de aquí.
4
00: 00: 20,440 -> 00: 00: 22,080
-No hay chocolate dentro de eso.
5
00: 00: 22,580 -> 00: 00: 23,960
-Sí hay
Here is the contents of my source "captions.srt" file:
1
00:00:06,800 --> 00:00:11,040
-We have to figure out how to open this!
2
00:00:11,080 --> 00:00:13,040
-What are you doing with that nickel?
3
00:00:13,160 --> 00:00:20,440
-That's why we need to get the chocolate money out of here
4
00:00:20,440 --> 00:00:22,080
-There's no chocolate inside that.
5
00:00:22,580 --> 00:00:23,960
-Yes there is
*EDIT:
I'm trying to compare each line of the source .srt file with the string I named "captrans". "captrans" contains rows of "sourcetext,translatedtext". I'm splitting on commas, reading each line of source file and if source file line matches (before comma) captrans then replace with (after comma) captrans. Hope this makes sense...
Thank you for any help you can provide!
web-scraping vbscript iteration writefile
1
You are reading the line to test, then you read it again to do something. So if line 1 = dosomething you dosomething to the next line. PutReadLineinto a variable, then test and operate on the variable.
– Noodles
Mar 23 at 21:18
@Noodles "for each a in splitfile" should be the same as readline, right? It feeds me each line of the source .srt file. I think my issue lies in the parsing of the captrans string... or in my comparison method.
– Drivium
Mar 23 at 21:45
I believe he is referring to these two lines:if instr(objFile.Readline,">") then capText = capText & objFile.ReadLine & vbcrlf.
– K.Dᴀᴠɪs
Mar 23 at 21:51
@K.Dᴀᴠɪs - that section is working ok. That section just takes the text parts (not line numbers or times) and uses those to get translations from the site. The part I'm struggling with is replacing the correct lines from the source file and merging changes into a new file. I updated OP with a little more context (at the bottom).
– Drivium
Mar 23 at 21:54
I commented the problematic section in the code
– Drivium
Mar 23 at 21:58
add a comment |
I'm making a little .srt translator tool that will scrape each text line of a .srt file, translate via google translate, and make the replacements into a new file. I've got everything done except for make the actual replacements. Seems like it should be easy, but I'm struggling with the iteration.
Here's my code:
Set IE = CreateObject("internetexplorer.application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
SourceCaptionFile = objFSO.GetParentFolderName(WScript.ScriptFullName) & "captions.srt"
OutputCaptionFile = objFSO.GetParentFolderName(WScript.ScriptFullName) & "NEW_captions.srt"
on error resume next
langURL_es = "https://translate.google.com/#view=home&op=translate&sl=en&tl=es"
'============================================================
Set objFile = objFSO.OpenTextFile(SourceCaptionFile, 1, true) 'for reading
Do until objFile.AtEndOfStream
if instr(objFile.Readline,">") then
capText = capText & objFile.ReadLine & vbcrlf
end if
loop
objFile.Close
'============================================================
'Navigate to translator and get translations
IE.Visible = true
IE.Navigate langURL_es
Do While IE.Busy or IE.ReadyState <> 4: WScript.sleep 100: Loop
Do Until IE.Document.ReadyState = "complete": WScript.sleep 100: Loop
wscript.sleep 1000
capline = split(capText,vbcrlf)
for i = 0 to ubound(capline)
ie.document.getelementbyid("source").innertext = capline(i)
Do While IE.Busy or IE.ReadyState <> 4: WScript.sleep 100: Loop
Do Until IE.Document.ReadyState = "complete": WScript.sleep 100: Loop
for each div in ie.document.getelementsbytagname("div")
if div.getAttribute("class") = "result-shield-container tlid-copy-target" then
captrans = captrans & capline(i-1) & "," & div.innertext & vbcrlf
end if
next
next
'============================================================
'**************THIS IS THE SECTION THAT'S NOT WORKING RIGHT**************
'compare translations against captions.srt file and make replacements
Set objFile = objFSO.OpenTextFile(SourceCaptionFile, 1, true) 'for reading
splitfile = split(objfile.readall,vbcrlf)
for each a in splitfile
arrCaptrans = split(captrans,",")
for i = 0 to ubound(arrCaptrans)
if a = arrCaptrans(i) then
newline = newline & arrCaptrans(i+1) & vbcrlf
else
newline = newline & a & vbcrlf
end if
next
next
objFile.Close
wscript.echo newline
'============================================================
'Write translated file
Set objTransFile = objFSO.OpenTextFile(OutputCaptionFile, 2, true) 'for writing
objTransFile.write newline
objTransFile.Close
'============================================================
wscript.echo "Done"
Here is the output I'm expecting:
1
00: 00: 06,800 -> 00: 00: 11,040
-¡Tenemos que averiguar cómo abrir esto!
2
00: 00: 11,080 -> 00: 00: 13,040
-¿Qué haces con ese nickel?
3
00: 00: 13,160 -> 00: 00: 20,440
-Por eso necesitamos sacar el dinero del chocolate de aquí.
4
00: 00: 20,440 -> 00: 00: 22,080
-No hay chocolate dentro de eso.
5
00: 00: 22,580 -> 00: 00: 23,960
-Sí hay
Here is the contents of my source "captions.srt" file:
1
00:00:06,800 --> 00:00:11,040
-We have to figure out how to open this!
2
00:00:11,080 --> 00:00:13,040
-What are you doing with that nickel?
3
00:00:13,160 --> 00:00:20,440
-That's why we need to get the chocolate money out of here
4
00:00:20,440 --> 00:00:22,080
-There's no chocolate inside that.
5
00:00:22,580 --> 00:00:23,960
-Yes there is
*EDIT:
I'm trying to compare each line of the source .srt file with the string I named "captrans". "captrans" contains rows of "sourcetext,translatedtext". I'm splitting on commas, reading each line of source file and if source file line matches (before comma) captrans then replace with (after comma) captrans. Hope this makes sense...
Thank you for any help you can provide!
web-scraping vbscript iteration writefile
I'm making a little .srt translator tool that will scrape each text line of a .srt file, translate via google translate, and make the replacements into a new file. I've got everything done except for make the actual replacements. Seems like it should be easy, but I'm struggling with the iteration.
Here's my code:
Set IE = CreateObject("internetexplorer.application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
SourceCaptionFile = objFSO.GetParentFolderName(WScript.ScriptFullName) & "captions.srt"
OutputCaptionFile = objFSO.GetParentFolderName(WScript.ScriptFullName) & "NEW_captions.srt"
on error resume next
langURL_es = "https://translate.google.com/#view=home&op=translate&sl=en&tl=es"
'============================================================
Set objFile = objFSO.OpenTextFile(SourceCaptionFile, 1, true) 'for reading
Do until objFile.AtEndOfStream
if instr(objFile.Readline,">") then
capText = capText & objFile.ReadLine & vbcrlf
end if
loop
objFile.Close
'============================================================
'Navigate to translator and get translations
IE.Visible = true
IE.Navigate langURL_es
Do While IE.Busy or IE.ReadyState <> 4: WScript.sleep 100: Loop
Do Until IE.Document.ReadyState = "complete": WScript.sleep 100: Loop
wscript.sleep 1000
capline = split(capText,vbcrlf)
for i = 0 to ubound(capline)
ie.document.getelementbyid("source").innertext = capline(i)
Do While IE.Busy or IE.ReadyState <> 4: WScript.sleep 100: Loop
Do Until IE.Document.ReadyState = "complete": WScript.sleep 100: Loop
for each div in ie.document.getelementsbytagname("div")
if div.getAttribute("class") = "result-shield-container tlid-copy-target" then
captrans = captrans & capline(i-1) & "," & div.innertext & vbcrlf
end if
next
next
'============================================================
'**************THIS IS THE SECTION THAT'S NOT WORKING RIGHT**************
'compare translations against captions.srt file and make replacements
Set objFile = objFSO.OpenTextFile(SourceCaptionFile, 1, true) 'for reading
splitfile = split(objfile.readall,vbcrlf)
for each a in splitfile
arrCaptrans = split(captrans,",")
for i = 0 to ubound(arrCaptrans)
if a = arrCaptrans(i) then
newline = newline & arrCaptrans(i+1) & vbcrlf
else
newline = newline & a & vbcrlf
end if
next
next
objFile.Close
wscript.echo newline
'============================================================
'Write translated file
Set objTransFile = objFSO.OpenTextFile(OutputCaptionFile, 2, true) 'for writing
objTransFile.write newline
objTransFile.Close
'============================================================
wscript.echo "Done"
Here is the output I'm expecting:
1
00: 00: 06,800 -> 00: 00: 11,040
-¡Tenemos que averiguar cómo abrir esto!
2
00: 00: 11,080 -> 00: 00: 13,040
-¿Qué haces con ese nickel?
3
00: 00: 13,160 -> 00: 00: 20,440
-Por eso necesitamos sacar el dinero del chocolate de aquí.
4
00: 00: 20,440 -> 00: 00: 22,080
-No hay chocolate dentro de eso.
5
00: 00: 22,580 -> 00: 00: 23,960
-Sí hay
Here is the contents of my source "captions.srt" file:
1
00:00:06,800 --> 00:00:11,040
-We have to figure out how to open this!
2
00:00:11,080 --> 00:00:13,040
-What are you doing with that nickel?
3
00:00:13,160 --> 00:00:20,440
-That's why we need to get the chocolate money out of here
4
00:00:20,440 --> 00:00:22,080
-There's no chocolate inside that.
5
00:00:22,580 --> 00:00:23,960
-Yes there is
*EDIT:
I'm trying to compare each line of the source .srt file with the string I named "captrans". "captrans" contains rows of "sourcetext,translatedtext". I'm splitting on commas, reading each line of source file and if source file line matches (before comma) captrans then replace with (after comma) captrans. Hope this makes sense...
Thank you for any help you can provide!
web-scraping vbscript iteration writefile
web-scraping vbscript iteration writefile
edited Mar 23 at 22:01
Drivium
asked Mar 23 at 21:14
DriviumDrivium
307219
307219
1
You are reading the line to test, then you read it again to do something. So if line 1 = dosomething you dosomething to the next line. PutReadLineinto a variable, then test and operate on the variable.
– Noodles
Mar 23 at 21:18
@Noodles "for each a in splitfile" should be the same as readline, right? It feeds me each line of the source .srt file. I think my issue lies in the parsing of the captrans string... or in my comparison method.
– Drivium
Mar 23 at 21:45
I believe he is referring to these two lines:if instr(objFile.Readline,">") then capText = capText & objFile.ReadLine & vbcrlf.
– K.Dᴀᴠɪs
Mar 23 at 21:51
@K.Dᴀᴠɪs - that section is working ok. That section just takes the text parts (not line numbers or times) and uses those to get translations from the site. The part I'm struggling with is replacing the correct lines from the source file and merging changes into a new file. I updated OP with a little more context (at the bottom).
– Drivium
Mar 23 at 21:54
I commented the problematic section in the code
– Drivium
Mar 23 at 21:58
add a comment |
1
You are reading the line to test, then you read it again to do something. So if line 1 = dosomething you dosomething to the next line. PutReadLineinto a variable, then test and operate on the variable.
– Noodles
Mar 23 at 21:18
@Noodles "for each a in splitfile" should be the same as readline, right? It feeds me each line of the source .srt file. I think my issue lies in the parsing of the captrans string... or in my comparison method.
– Drivium
Mar 23 at 21:45
I believe he is referring to these two lines:if instr(objFile.Readline,">") then capText = capText & objFile.ReadLine & vbcrlf.
– K.Dᴀᴠɪs
Mar 23 at 21:51
@K.Dᴀᴠɪs - that section is working ok. That section just takes the text parts (not line numbers or times) and uses those to get translations from the site. The part I'm struggling with is replacing the correct lines from the source file and merging changes into a new file. I updated OP with a little more context (at the bottom).
– Drivium
Mar 23 at 21:54
I commented the problematic section in the code
– Drivium
Mar 23 at 21:58
1
1
You are reading the line to test, then you read it again to do something. So if line 1 = dosomething you dosomething to the next line. Put
ReadLine into a variable, then test and operate on the variable.– Noodles
Mar 23 at 21:18
You are reading the line to test, then you read it again to do something. So if line 1 = dosomething you dosomething to the next line. Put
ReadLine into a variable, then test and operate on the variable.– Noodles
Mar 23 at 21:18
@Noodles "for each a in splitfile" should be the same as readline, right? It feeds me each line of the source .srt file. I think my issue lies in the parsing of the captrans string... or in my comparison method.
– Drivium
Mar 23 at 21:45
@Noodles "for each a in splitfile" should be the same as readline, right? It feeds me each line of the source .srt file. I think my issue lies in the parsing of the captrans string... or in my comparison method.
– Drivium
Mar 23 at 21:45
I believe he is referring to these two lines:
if instr(objFile.Readline,">") then capText = capText & objFile.ReadLine & vbcrlf.– K.Dᴀᴠɪs
Mar 23 at 21:51
I believe he is referring to these two lines:
if instr(objFile.Readline,">") then capText = capText & objFile.ReadLine & vbcrlf.– K.Dᴀᴠɪs
Mar 23 at 21:51
@K.Dᴀᴠɪs - that section is working ok. That section just takes the text parts (not line numbers or times) and uses those to get translations from the site. The part I'm struggling with is replacing the correct lines from the source file and merging changes into a new file. I updated OP with a little more context (at the bottom).
– Drivium
Mar 23 at 21:54
@K.Dᴀᴠɪs - that section is working ok. That section just takes the text parts (not line numbers or times) and uses those to get translations from the site. The part I'm struggling with is replacing the correct lines from the source file and merging changes into a new file. I updated OP with a little more context (at the bottom).
– Drivium
Mar 23 at 21:54
I commented the problematic section in the code
– Drivium
Mar 23 at 21:58
I commented the problematic section in the code
– Drivium
Mar 23 at 21:58
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318459%2fvbscript-to-compare-each-line-of-string-to-each-line-of-text-file-and-make-repla%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318459%2fvbscript-to-compare-each-line-of-string-to-each-line-of-text-file-and-make-repla%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You are reading the line to test, then you read it again to do something. So if line 1 = dosomething you dosomething to the next line. Put
ReadLineinto a variable, then test and operate on the variable.– Noodles
Mar 23 at 21:18
@Noodles "for each a in splitfile" should be the same as readline, right? It feeds me each line of the source .srt file. I think my issue lies in the parsing of the captrans string... or in my comparison method.
– Drivium
Mar 23 at 21:45
I believe he is referring to these two lines:
if instr(objFile.Readline,">") then capText = capText & objFile.ReadLine & vbcrlf.– K.Dᴀᴠɪs
Mar 23 at 21:51
@K.Dᴀᴠɪs - that section is working ok. That section just takes the text parts (not line numbers or times) and uses those to get translations from the site. The part I'm struggling with is replacing the correct lines from the source file and merging changes into a new file. I updated OP with a little more context (at the bottom).
– Drivium
Mar 23 at 21:54
I commented the problematic section in the code
– Drivium
Mar 23 at 21:58