Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Add a string value from a data file to new file.  (Read 2108 times)

0 Members and 1 Guest are viewing this topic.

mjedski2

  • Guest
Add a string value from a data file to new file.
« on: February 24, 2006, 05:14:52 PM »
I have been trying to find a way to read a string from a data file, then copy this to the end of a string in a different file.
I have tried the copy command (a1.txt+data.dat comb.bat>nul) and it seems to copy the data to the next line and not to the end of the line.

For example I would like to copy the string "123456" from file data.dat and append it to the line "<command> /a /b g:" and make this a batch file that can be executed.
The resulting bacth line would look like "<command> /a /b g:123456" in the batch file.

mjedski :)

carlos

  • Guest
Re: Add a string value from a data file to new fil
« Reply #1 on: February 25, 2006, 05:16:05 AM »
The next will work if there isn't any special characters in the command (like < or |)

Code: [Select]
for /f "tokens=*" %%c in (a1.txt) do set command=%%c
for /f "tokens=*" %%d in (data.dat) do echo %command%%%d > comb.bat
« Last Edit: February 25, 2006, 05:21:23 AM by carlos »