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

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

Appends the current date string to an archive name when creating or processing 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:

Yyear

Mmonth

MMMmonth as text string (Jan, Feb, etc.)

Wa week number (a week starts with Monday)

Aday of week (Monday is 1, Sunday is 7)

Dday of month

Eday of year

Hhours

Mminutes (treated as minutes if encountered after hours)

Iminutes (treated as minutes regardless of hours position)

Sseconds

Narchive number (numeric value starting from 1).
When archiving, WinRAR searches for already existing archive with generated name and if found, increments the archive number until generating an unused name. 'N' format character is not supported when creating volumes .
When performing non-archiving operations like extracting, WinRAR selects the existing archive preceding the first unused name or sets N to 1 if no such archive exists.

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 process 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 or open a new archive instead of processing the already existing one. You may use -log switch to write the generated archive name to a file and then read it from file for further processing.

Examples

use the default YYYYMMDDHHMMSS format

WinRAR a -ag backup

use DD-MMM-YY format

WinRAR t -agDD-MMM-YY backup

use YYYYMMDDHHMM format, place date before 'backup '

WinRAR a -ag+YYYYMMDDHHMM backup

use YYYY-WW-A format, include fields description

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

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