logo

Rend - A log rotator helper
Written by Håkan Ståby   

Rend - A log rotator helper. A small Windows console application that renames a file or folder. The snippet inserts current date before the filename/folder

Background

I made this snippet (=small program) in about 20 minutes because I needed a tool to rotate Oracle logs on Windows. I couldn't find a snippet like this on the Internet so I thought I would share it. Contact me if you have any questions, comments, or made a better version that you would like to share.

What the snippet does

The snippet is called rend.exe (rename with date) and lets you inserts date YYYYMMDD before the trailing filename or folder in the submitted filepath. If you want to use the program to rotate logs you would need to use the Windows scheduler or make some other tool run this program, of course. It is a console application, which means that it runs in a DOS window.

The snippet was written in C using MS Visual Studio 6.0. The source code can be downloaded and modified to suit your needs e.g. write the date in another way.

Usage

rend <filepath>
Example: "rend C:\file.log" produces "C:\20021010file.log"

Download

Download the source code. You are free do what you like with it.
Download the binary for windows. (It has only been tested on Windows XP and 2000.)