Text File - Concatenate

June 28, 2010 at 08:38:12
Specs: Windows XP
I have a batch file gathering information from our system and writing to a text file. I need to concatenate the context of the data file into a single.

text file output (tmp.dat)

I want this to end up reading:


See More: Text File - Concatenate

Report •

June 28, 2010 at 09:41:35
It may be possible to do it in the batch that creates the data file.
Could you provide the original batch? Or a redacted version of it?

Insomniac at large

Report •

June 28, 2010 at 09:45:34
This is what I have so far:

echo MAX, >>tmp.dat

set DATESTAMP=%DATE:~4,2%-%DATE:~7,2%-%DATE:~10,4%
echo %DATESTAMP%,>>tmp.dat

@echo off
for /f "tokens=1,2 delims==" %%a in (C:\db\db.ini) do (
if %%a==DbDBMS set DbDBMS=%%b

echo %DbDBMS%, >> tmp.dat

systeminfo.exe /nh /fo CSV >> tmp.dat

After this runs, I have another batch calling an awk script that will take the , delms and replace with |

I need to get everything into 1 line, then will BCP to database.


Report •

June 28, 2010 at 11:45:27
Try this:

@ECHO off 
SET one_liner=MAX
SET DATESTAMP=%DATE:~4,2%-%DATE:~7,2%-%DATE:~10,4%
SET one_liner=%one_liner%,%DATESTAMP%
FOR /f "tokens=1,2 delims==" %%a IN (C:\db\db.ini) DO ( 
    IF %%a==DbDBMS SET DbDBMS=%%b 
SET one_liner=%one_liner%,%DbDBMS%,
FOR /F "tokens=* delims=" %%a IN ('systeminfo.exe /nh /fo CSV') DO (
    SET one_liner=%one_liner%%%a
ECHO.%one_liner% >>tmp.dat

Edit: Updated because I missed that you need EVERYTHING in one line, not just the first part... The above puts it all in one line for me now.

Insomniac at large

Report •

Related Solutions

June 28, 2010 at 12:13:36
That worked great for the first set of lines. Thank you.

Is it possible to pull the systeminfo output into the same line?


Report •

June 28, 2010 at 12:58:43
Yep, sorry. See Response 3 for an updated version.

Insomniac at large

Report •

Ask Question