Dec 132017
 
Batch file utility that sets the dos errorlevel=age of a file. Author wrote it for his autoexec.bat to make sure he only ran certain utilities once a day no matter how many times he re-booted the computer.
File FILEAGE.ZIP from The Programmer’s Corner in
Category Batch Files
Batch file utility that sets the dos errorlevel=age of a file. Author wrote it for his autoexec.bat to make sure he only ran certain utilities once a day no matter how many times he re-booted the computer.
File Name File Size Zip Size Zip Type
FILEAGE.COM 572 507 deflated
READ.ME 2954 1500 deflated

Download File FILEAGE.ZIP Here

Contents of the READ.ME file



Fileage v1.0June 25th, 1991
A File age testing mechanism for BAT files

Copyright (C) 1991Raymond J Berry
Bellevue, Wash.
C$: 73407,3152

[legal: You may freely use this program in either a private or
commercial setting. You may not sell it or otherwise profit
monetarily from it.]

{ Yes, it seems silly to copyright a 600 byte .com file, but...}

For the last couple years I've been looking for some handy way of
controlling my bootup so that I only run certain things the first
time I boot on a given day - particularly, in my case, Norton "FR",
analogous to PCTools MIRROR.

I kept telling myself this is too obvious a requirement not to have
been fulfilled by countless reams of utilities, but I've never seen
a simple way of doing it. Therefore, I finally decided to write a
util to do this, and FILEAGE is the result.

FILEAGE calculates the difference in days between the system date
and the age of a single file given as the sole argument to the
program. The filename may have a drive designator and a directory
path but it may not contain the standard dos wildcard characters
'*' or '?'. Any file permission will be found, including read-only,
system, or hidden files.

For ease of BAT file usage, FILEAGE reports the file's age in days
as the exit code from the program, making for easy ERRORLEVEL testing.

To increase the versatility of the util, the age in days is also
output as a decimal ascii string to STDOUT so that it can be used
to set shell variables if you and your shell are so inclined (e.g.,
var=`fileage ` ). This also makes it possible for the
operator to discern the program output.

The exit code returned via DOS is a byte value and hence limited to
255. The 255 value is reserved for two possible error conditions:

(1) The file could not be found.
(2) A Wildcard was encountered in the filename argument.

In addition to the 255 return, the two conditions above will trigger
an error message to the STDERR output, and print '-1' to STDOUT.

If the file is more than 254 days old, the exit code is set to 254.
For such files, the ascii decimal output will still be correct.
The intent of the is primarily to distinguish between relatively
recent filedates and hence the 8 bit return limitation is not deemed
significant.

Since the system date changes at midnight, FILEAGE will return zero
for files created on the same calendar day. This makes it simple
to do things once-a-day via

FILEAGE d:\image.dat
IF NOT ERRORLEVEL 1 GOTO NO_IMAGE
IMAGE D:
:NO_IMAGE
...

If the file doesn't exist (deleted, never made, etc.,) it would
get created via the above scenario, since the return code would be
255 == non-zero.

It should be a simple matter to use similar schemes to do things
once a week, etc.

I hope you find FILEAGE useful.

*EOF*


 December 13, 2017  Add comments

Leave a Reply