version 1.04
version 1.04
version 1.04
version 1.04

version 1.04



I admit it - I love logs! But I just hate the space they take up... If only there were some way to archive them into some sort of intuitive format. Ah, it's only a dream... Until now!

AnalogX Sarch allows you to archive logs, delete files using times and dates in your wildcards, and more. How does it do this? Simple, Sarch is basically a command executer with a limited number of variables that can be output as parameters. It sounds more difficult than it really is, things will be clearer in a moment.

Sarch is like most command line utilities out there; from the command prompt you can type the name by itself to get a list of options:

F:\tools\sarch> sarch

AnalogX Sarch version 1.00 (Release)
The latest version can always be found at

Usage:   Sarch [options]
Options:   /TARGET [path]      Destination for files
           /SOURCE [path]      Source for files (def: current)
           /FILENAME [name]    Destination filename
           /WILDCARD [match]   String to use to find matches (ie; ex12*.log)
           /OFFSET [time]      Time to offset (ie; 1d=1day, 10h=10hours)
           /EXECUTE [...]      Command to execute

Here's a brief description of each option:
    TARGET      This is the path where you want the files to be copied to.  It
                supports both relative (..\) paths or literal paths (C:\).  I
                would recommend using literal whenever possible to eliminate
                any possible ambiguity, unless you are comfortable with using
                relative paths.
    SOURCE      This is the directory it is going to be working in.  If no
                source directory is specified, then it will use the current
                mounted path.
    FILENAME    This specifies the destination filename - this is purely
                optional, but can sometimes help to make things a bit more
                intuitive when you are using the same filenames for multiple
    WILDCARD    This is another optional option (imagine that).  As with the
                FILENAME, it's purpose is to help clean up multiple use
    OFFSET      This is the amount of time to offset the current time by.
                Different units may be used (h = hour, d = day, m = month,
                y = year), and mixed units may be specified, so 1d5h is a
                valid offset.
    EXECUTE     This is the actual string that will be executed.

Now, before we move on to some examples of how you use this program, we need to cover what variables are an how they're used. The primary purpose of this program is to help in using time values in execution strings, so almost all the variables are time-related. Let's assume you have a variable named HOUR that's set to the number 5 (for 5 hours), you would execute this:

    echo {HOUR}

which would in turn execute this:

    echo 5

See? The {HOUR} is translated into whatever it is set to before it does anything. It's also important to point out that all variables MUST start with a { and end with a }. Also, while they are not case sensitive, they must be punctuated exactly as noted in these docs. Here's the list of variables supported:

    Time.Month              Displays the month in numeric form, 1-12
    Time.MonthPad           Same as Time.Month, but will always be two digits,
                            so 03 instead of 3.
    Time.Day                Displays the day in numeric form, 1-32
    Time.DayPad             Same as Time.Day, but will always be two digits,
                            so 09 instead of 9.
    Time.Year2              Displays the year in two digit for (2001 = 01)
    Time.Year4              Displays the year in numeric form
    Config.Filename         The processed filename
    Config.Source           The processed source directory
    Config.Target           The processed target directory
    Config.Wildcard         The processed wildcard specification

So let's use this in an example. Let's say that you're running IIS with logs turned on, and set to be created weekly (so you end up with 4 or 5 logs per month. Normally IIS names it's logs something like 'ex010704.log', which means extended (EX) 2001 (01) July (07) fourth week (04), got it? So what we want to do is to zip these up using WinZip and put them in another directory:

sarch /source "C:\Logs\" /target "{Config.Source}archive\{Time.Year4}\" /wildcard "ex{Time.Year2}{Time.MonthPad}??.log" /OFFSET -1m /filename "{Time.MonthPad}{Time.Year4}.zip" /execute "C:\WinZip\wzzip -ex {Config.Target}{Config.Filename} {Config.Source}{Config.Wildcard}"
sarch /source "C:\Logs\" /target "{Config.Source}archive\{Time.Year4}\" /wildcard "ex{Time.Year2}{Time.MonthPad}??.log" /OFFSET -1m /filename "{Time.MonthPad}{Time.Year4}.zip" /execute "del {Config.Source}{Config.Wildcard}"

WHEW! Those are some long commands! So here's what we're basically saying; Look inside the C:\Logs directory, for any files that start off with ex and the current year and month, minus one month. Notice we pick Year2 since we need a two digit year, and MonthPad since we need to ensure the month is always two digits as well. The ?? simply tells DOS to match any two characters. This then get's translated into the WinZip string (make sure you have the WinZip command line option installed), which is output into the directory C:\Logs\archive\2001\ (assuming the year is 2001). The second command is exactly the same as the first, but instead of executing WinZip, it executes the DOS command DEL to delete the files which were compressed.

If you need to enclose something in quotes, such as a path with spaces in it, and use it as a parameter, then you must enclose it in double quotes:

BAD:    sarch /execute "C:\WinZip\wzzip -ex C:\Program Files\Whatever.exe"
GOOD:   sarch /execute "C:\WinZip\wzzip -ex ""C:\Program Files\Whatever.exe"""

These 'escaped' quotes will be passed through the program.

If for some reason either the source or destination directories do not exist, the program will create them before executing the command. This is to help ensure that the executed command doesn't fail because it doesn't gracefully handle non-existent directories.