Switch -AG[format] - generate archive name using the current date and time


Appends the current date string to an archive name when creating an archive. Useful for daily backups.

Format of the appending string is defined by the optional format parameter or by "YYYYMMDDHHMMSS" if this parameter is absent. The format string may include the following characters:

Y year
M month
MMM month as text string (Jan, Feb, etc.)
W a week number (a week starts with Monday)
A day of week (Monday is 1, Sunday is 7)
D day of month
E day of year
H hours
M minutes (treated as minutes if encountered after hours)
S seconds
N archive number. WinRAR searches for already existing archive with generated name and if found, increments the archive number until generating a unique name. 'N' format character is not supported when creating volumes.

Each of format string characters listed above represents only one character added to archive name. For example, use WW for two digit week number or YYYY to define the four digit year.

If the first character in the format string is '+', positions of the date string and base archive name are exchanged, so a date will precede an archive name.

The format string may contain optional text enclosed in '{' and '}' characters. This text is inserted into archive name.

All other characters are added to an archive name without changes.

If you need to update an already existing archive, be careful with -ag switch. Depending on the format string and time passed since previous -ag use, generated and existing archive names may mismatch. In this case WinRAR will create a new archive instead of updating the already existing.

Examples

  1. use the default YYYYMMDDHHMMSS format

WinRAR a -ag backup

  1. use DD-MMM-YY format

WinRAR a -agDD-MMM-YY backup

  1. use YYYYMMDDHHMM format, place date before 'backup'

WinRAR a -ag+YYYYMMDDHHMM backup

  1. use YYYY-WW-A format, include fields description

WinRAR a -agYYYY{year}-WW{week}-A{wday} backup

  1. use YYYYMMDD and the archive number. It allows to generate unique names even when YYYYMMDD format mask used more than once in the same day

WinRAR a -agYYYYMMDD-NN backup