Windows Logfile Archival Script

I didn’t use a batch file because I like Ruby more. :wink: Also, this is just
a snippet from a much bigger program I wrote that’s a bit over 1000 lines.
Is it true that I would not have to use ftools? I though it was necessary
for Dir.chdir. I could easily be wrong since I’m a n00b. Thanks for the
input, Nobu.
Craig

Hi,

At Sat, 14 Feb 2004 03:15:14 +0900,
Moran, Craig M (BAH) wrote in [ruby-talk:92804]:

#/usr/bin/env ruby
require ‘ftools’

Dir.chdir(“C:/Logfiles”)
files = Dir[“*.log”]
files.each {|file| system(“"/Program Files/WinZip/WZZIP.EXE" -m
"C:\Logfiles\Archived.zip" " +”"" + file + “"”)}

You don’t need ftools.rb here.

BTW, why isn’t it enough with a batch file, or a shortcut?

@echo off
cd c:\LogFiles
“/Program Files/WinZip/WZZIP.EXE” -m C:\Logfiles\Archived.zip *.log

···

-----Original Message-----
From: nobu.nokada@softhome.net [mailto:nobu.nokada@softhome.net]


Nobu Nakada

Hi,

At Mon, 16 Feb 2004 23:15:36 +0900,
Moran, Craig M (BAH) wrote in [ruby-talk:92981]:

I didn’t use a batch file because I like Ruby more. :wink: Also, this is just
a snippet from a much bigger program I wrote that’s a bit over 1000 lines.
Is it true that I would not have to use ftools? I though it was necessary
for Dir.chdir. I could easily be wrong since I’m a n00b. Thanks for the
input, Nobu.

At least, you wouldn’t need to iterate for each files in ruby,
many zip tools accept multiple files at once.

ZIP = “/Program Files/WinZip/WZZIP.EXE”
Archive = “C:\Logfiles\Archived.zip”
system(ZIP, “-m”, Archive, Dir[".log"])

And Dir.chdir is a builtin method, which calls the underlying
system call.

···


Nobu Nakada