-2

I have a document with some random letters in it for example

line 1: k
line 2: l
line 3: m
line 4: n

and I want to read one line and change the letter which I have a script to do that already using below.

if "%name%"=="k" (goto k)

then I have this to set the new variable.

:k  
SET name=a  
goto echo  

then I have it to output into the other document using

:echo  
ECHO %name%>>newvarables.txt  
goto getinput

is there a way I can convert the lines of the first document into other variables based on the system I have already?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Kieran
  • 25
  • 1
  • 5
  • 1
    This looks like an oversimplified example and not the rreal task. To process every line of a file use a `for /f` - there are hundrds of examples on this site, use the search box above. [SO] isn't a script writing service, you should show a bit more research effort, learn the syntax of the commands on http://ss64.com/nt –  Aug 20 '17 at 19:32
  • I have researched on many sites outside of this play and nothing works with windows 10 properly or is not what I clearly stated in the description above I also used "replacing the line in text document" when searched on this forms and there are only 42 results, most of which are other languages, not MS-Dos. – Kieran Aug 20 '17 at 20:42
  • 1
    Maybe you don't get results because MS-Dos is the wrong key? Which OS do you really use? And to me your question is unclear. –  Aug 20 '17 at 20:48
  • Hmm.. Does adding **`Windows Batch`** to the search term makes the result more batch scripts? –  Aug 21 '17 at 10:33
  • This process is much simpler using a replacement [array](https://stackoverflow.com/questions/10166386/arrays-linked-lists-and-other-data-structures-in-cmd-exe-batch-script/10167990#10167990) – Aacini Aug 21 '17 at 14:55

1 Answers1

0

The following sample only works for WINDOWS NT systems!


for /f %%G in (filename.ext) do call :function "%%~G"
goto :eof

:function
set skip=rem
if "%~1"=="k" set name=a
if "%~1"=="l" set name=m
if not "%name%"=="" set skip=
%skip% echo %name%>>filename2.ext
exit /b

Loops through strings and process them, change to suit your need. This code is intended to be messy, so that:

One would need to put some effort on understanding, not just copy-paste my code.