Please enable JavaScript to view this site.

CopiaFacts™ Reference Manual

Command Expansion Utility

CFUTIL RUNDATE [[+|-]n[h|d|m|n]][$] command

The RUNDATE utility runs a console command with expansion of date or time values contained in the command string. It is provided to allow the automated processing of the CopiaFacts utilities such as CATDBFX which need a date in the command.

The parameter expansion is controlled by "%" symbols in the command string. The principal codes for use with dates are:

%d expands to day of month (01 - 31)
%m expands to month number (01 - 12)
%y expands to year (without century) (00 - 99)
%w expands to day of the week (Sunday is 0)

There are many other codes available, as documented for the ANSI standard C run-time function strftime(). The full list of available codes is as follows:

%a abbreviated weekday name
%A full weekday name
%b abbreviated month name
%B full month name
%c 'short' date and time representation for locale
%d day of the month (01-31)
%H hour in 24-hour format (00-23)
%I hour in 12-hour format (01-12)
%j day of year (001-366)
%m month (01-12)
%M minute (00-59)
%p am/pm indicator for locale
%S second (00-59)
%w weekday (0-6, Sunday is 0)
%W week number in year (00-53) (week starts on Monday)
%x 'short' date for locale
%X time for locale
%y year without century
%Y year with century
%z time zone abbreviation
%% percent sign

The date expanded is normally the current date, but to facilitate processing after a month has ended, RUNDATE has an optional parameter which will set the hour, month or day forward or back before performing the expansion. The examples below will make this clear.

Command-Line Arguments:

n the number of minutes (n) hours, days or months (m) to adjust from the current date/time before expansion. You can add or subtract up to 24 hours, 12 months or 65 days. The plus or minus sign is required if this optional adjustment parameter is included. If the n, h, d and m are omitted, d is assumed.
A $ sign as the last or only character of this parameter switches the RUNDATE % special symbol to be a $ sign.  This avoids conflict if you need to include shell parameters such as %1 or %envvar% in the command passed to RUNDATE.
command the command to be executed.  Double quotes are no longer necessary (from 8.3.0.185 onwards) around this command, though may be used to surround the whole command. The program name or any individual parameter that contains embedded blank space must be surrounded by single-quotes, which will always be converted to double-quotes by the RUNDATE process.  See these examples.
Unlike $run, the command is run in a CMD.exe session, so it is not necessary to prefix the command with CMD /c to run a batch file from CFUTIL RUNDATE.
If you include the whole CFUTIL RUNDATE command in a batch file, the normal batch file syntax rules require that you duplicate the "%" signs as "%%".

If you refer to the ANSI specifications of strftime(), note that the locale for RUNDATE is fixed as the USA. Thus full-date expansions will always come out as MM/DD/YY, whatever you have set as the country code. An exception is that %z expands to the current timezone of the machine.

Examples:

Assume that the program is being run on Wednesday September 2nd, 2015 and that all these command examples are run from within batch files.

Expand current date:

CFUTIL RUNDATE "RADATA2 %%y%%m%%d"

(runs: RADATA2 150902)

Expand date two days ago:

CFUTIL RUNDATE -2d "RADATA2 %%y%%m%%d"

(runs: RADATA2 150831)

Expand last month's date:

CFUTIL RUNDATE -1m "CATDBFX %%Y%%m"

(runs: CATDBFX 201508)

Display comment:

CFUTIL RUNDATE -1m "echo Making file for %%B %%Y"

(prints: Making file for August 2015)

Move yesterday's CopiaFacts error trace file to an archive (run on a Friday)

CFUTIL RUNDATE -1d "PKZIP -m KEEPTRC M1.TR%%w"

(moves M1.TR5 from the FAXFACTS folder to the ZIP file)

CFUTIL RUNDATE -1d$ "PKZIP -m KEEPTRC %%FFTRC%%\M1.TR$w"

(moves M1.TR5 from the trace folder to the ZIP file)

Use CFUTIL RUNDATE on a $run command:

  See these examples.