WinRar And Log Files
Apr 5th, 2007 at 3:43 pm by Jon
I ran across a rather interesting problem at work. …Actually, it wasn’t so much a problem as a minor issue. Everyone at my new job (I’m not going to be able to say that soon since I’ve almost been there for three weeks) uses Yahoo! Messenger to IM with each other. I’m primary an AIM user, but I did used to use Yahoo! a great deal in college.
The problem/issue I ran accross was what to do about my log files. I’m almost insane about my data (whether it be log files, camera pictures, or old project) and absolutly hate two things: the duplication and/or loss of said information. So, you can just imagine how many MBs of log files I have. Add to that the fact that I use Trillian (which lets me use AIM, MSN and Yahoo! at the same time) and the issue/problem, along with the log files, becomes bigger.
So, I decided to run Trillian at work in addition to home. That meant that I had to get my log files to and from the office back to my PC at the house. At first I thought about just FTP or email, but I quickly gave up on that since both are insecure. The next and by far most obvious choice was my USB flash drive.
After the transfer situation resolved itself, next I had to worry about the data. I really didn’t want to fill my drive up with log files every morning and night, so I decided to go with compression.I never really had done any coding with compression but after zipping and unzipping my log files (not to mention moving and deleting) to and from their location on the computer, I ended up sitting down to write a tiny java program. Even though I hate it, java comes with a built in ZIP library so it seemed like a good idea at the time. Oh, how wrong I was!
After saying screw it to java (I wont get into how angry I am at it), I ended up looking into WinRar. Not only does it compress files better than WinZip (at the cost of speed) but it also gives user the ability to run command line parameters. Add that to the fact that you can actually use it without getting tons of messages about buying it (remember, I’m a poor ex-college student) and you end up with something great!
So, here is the end result. The first file compresses the Trillian log files and moves it to my usb drive while the second one grabs the archive from my drive to place them into the proper location. You’ll note that I don’t delete the files. This is because I like to have full control and just place them into the Recycle Bin. You never know what will happen, so just in case…
Import.bat
@echo off
cls
echo Importing Trillian log files from USB Drive.....
@setlocal
set path="C:\Program Files\WinRAR\";%path%
copy /y r:\logs.rar c:\logs.rar
rar x -inul -o+ c:\logs.rar c:\
move /y c:\users "c:\program files\trillian"
move /y c:\logs.rar "c:\documents and settings\all users\desktop"
Export.bat
@echo off
cls
echo Exporting Trillian log files to USB Drive.....
@setlocal
set path="C:\Program Files\WinRAR\";%path%
rar a -ep1 -inul -m5 -rr10 -s c:\logs.rar "c:\program files\trillian\users"
copy /y c:\logs.rar r:\logs.rar
move /y c:\logs.rar "c:\documents and settings\all users\desktop"
move /y "c:\program files\trillian\users" "c:\documents and settings\all users\desktop"