1.

Solve : appending log files into a single file.?

Answer»

I have series of log files.I want to append all of them into a single file.I want the log file name to be appended before the log text.After appending,all the log files to be deleted.
Following code MAY help you

Code: [Select]@echo off
set logfile=C:\log.txt
if exist "%logfile%" del "%logfile%"
for /f "tokens=*" %%a in ('dir /b /s *.log') do type "%%a" >> "%logfile%"
for /f "tokens=*" %%a in ('dir /b /s *.log') do call del "%%a"
it copies the content of all lof files in one txt file and delete them after that thanks .I also want to append the name of the log file before appending its contents.
How do I go about that?Quote from: doslearner on September 18, 2008, 12:06:44 AM

thanks .I also want to append the name of the log file before appending its contents.
How do I go about that?

Code: [Select]@echo off
set logfile=log.txt
if exist "%logfile%" del "%logfile%"
for /f "tokens=*" %%a in ('dir /b /s *.log') do (
echo **** %%a **** >> %logfile%
type "%%a" >> "%logfile%"
)
del *.log
Thanks a lot.It worksQuote from: doslearner on September 18, 2008, 12:56:04 AM
It works

I know.

Glad to help. Good luck!
Happy New Year.

I think my problem is somewhat similar to above.

I will try to explain what exactly I want.

I have some trend files in *.hst format which will generate everyday with that day's time & date stamp in file name & I have one tool which covert these *.Hst files in 2 text files with extensions *.txt & *.hdr.

*.hdr file contains only headers of that data.
exa.
3
Header1
Header2
Header3
In above exa. 3 MEANS no. of parameters & Header 1, 2, 3 are headers of data.

*.txt file contains all data of that whole day with same 3 parameters.

exa.

Date Time Header1 Data Header2 Data Header3 Data

I want to combine these 2 files in single excel file because again I want to use this excel file for report generation.

I want to copy headers Header1, Header2, Header3 in first row & Column C, D & E respectively. In column A & B, I want to write 'Date' & 'Time' respectively because my *.txt file contain Date & time but header file not contain header for Date & Time.
Then I want to copy all Data from *.txt file to excel file below respective header.

I want to do this with a single click that's why I am trying to do this with run the batch file.

By using below code we can replace *.txt file in *.XLS.

Code:
set dr=%systemdrive%\yourfolderpath&CLS
for /f "tokens=1*" %%a in ('dir /a %dr% /b') do (
call copy "%dr%\%%a%%b"
rename * *.EXL
)

But I want to copy headers in first row of this *.xls file.


Is It Possible?
Waiting for Ur reply.


Discussion

No Comment Found