This is my first stop so please point out any errors I have made into my post or way of resolving this problem! So, I have a small project with my friends in which we have to make a batch script in which it has to access a text file with a few words on the first lines. Selecting one word at the time, we have to access a site and find it a synonym and paste the result. Here is what I have done so far:
@echo off
title Prg1
set COS=
:b
for /f "Delims=%COS%" %%a in (word.txt) do (
set SIN=%%a
set COS=%SIN%
)
cd C:\
cd Folder
* finds synonim
:Ask
echo Change the word " %SIN% " with the above word? (Y/N)
set INPUT=
set /P INPUT=Type input: %=%
If /I "%INPUT%"=="y" goto yes
If /I "%INPUT%"=="n" goto no
:yes
*send synonym* >> sinonim.txt
echo The transfer was succesful!
pause
goto :b
OK so I am sorry that I wasn't able to put the code in a box just like the other posts, I wasn't able to figure it out. Alright then, I have 2 errors:
1) At the beginning of the program I gave COS the value of space so when it would enter the for loop the delimiter would be the space too. I then asigned SIN the value of the first word in the text file. Right after that I gave COS the same value as SIN so after all the other commands would be executed, goto :b would return me to the for loop and I would have a new delimiter: the first word in the text thus SIN will then be set as the second word and the loop begins again. My problem is that even though COS got the SIN value, when it accesses the loop it one again has the space value so the script has no choice but do the same thing over and over again. What should I do?
2) When the command send synonym >> sinonim.txt
executes it places the new word on a new line. Now, I have researched this for quite a while today but I couldn't solve it since the code is something like this : (grep "blabla" blah.html) >> sinonim.txt.
I tried to write it as (echo|set /p=(grep "blabla" blah.html)) >> sinonim.txt
but it didn't work. Again, what should I do?
I would really appreciate if you could answer both of my question StackOverflow Community! Have a great day!