Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Concatenating All Log Files But Last One

9 views
Skip to first unread message

Five By Five

unread,
Apr 8, 2013, 5:27:19 PM4/8/13
to
I am trying to write a CMD batch file script that concatenates the text
(lines) of ALL BUT LAST ONE the files (Apache logs) in time order.

1. Assume the batch (.bat) file is in the same directory
2. Assume the files are named "prefix-ddmmmmyyyy.log" where 'prefix-' and
'.log' are unvarying characters in the file name.

How would that be done?

The last file is actively being written to by the server, which is why I
don't concatenate.

Auric__

unread,
Apr 9, 2013, 2:28:48 AM4/9/13
to
Five By Five wrote (in comp.os.msdos.programmer):
I have nothing useful to add, except to point you at alt.msdos.batch.nt,
where the batch experts dwell. (Followup-to set accordingly.)

--
One should never legalize a hot romance.
-- Sylvia Sidney

Herbert Kleebauer

unread,
Apr 9, 2013, 3:39:15 AM4/9/13
to
On 09.04.2013 08:28, Auric__ wrote:
> > Five By Five wrote (in comp.os.msdos.programmer):
> >
>> >> I am trying to write a CMD batch file script that concatenates the text
>> >> (lines) of ALL BUT LAST ONE the files (Apache logs) in time order.
>> >>
>> >> 1. Assume the batch (.bat) file is in the same directory
>> >> 2. Assume the files are named "prefix-ddmmmmyyyy.log" where 'prefix-' and
>> >> '.log' are unvarying characters in the file name.
>> >>
>> >> How would that be done?

If the file dates are in the same order than the dates
in the file name, you can use:

@echo off
set list=nul
set last=
for /f %%i in ('dir /b /od *.log') do (
if defined last call set list=%%list%%+%%last%%
set last=%%i)
copy /b %list% all.txt

Five By Five

unread,
Apr 9, 2013, 10:57:11 AM4/9/13
to
Herbert Kleebauer <kl...@unibwm.de> wrote on Tue 09 Apr 2013 12:39:15a
Impressive. That worked nicely. Thanks
0 new messages