AppendDate is a small CLI based program for MorphOS. It can be used for automation of naming logs or similar periodically created files, when an application generating them can't do it itself, or naming scheme is not flexible enough. The program is distributed as freeware with full source code on BSD two-clause license.
Usage: AppendDate FILE/A, DAYS/K/N, FORMAT/K, PREFIX/S, EXTENSION=EXT/S
- FILE – A path to a file or directory, which name is to be changed. May be absolute or relative to the current dir. This argument is required. In case of directory name, it must not contain the trailing '/'.
- DAYS – Optional offset between current date and the date to be appended. For example DAYS=-1 will append yesterday date. The default value is 0 (today). Note that resulting date can't be earlier than 1978-01-01.
- FORMAT – Optional date format specifier. It is a string with
printf()-like placeholders replaced by date components. Date string in this
case is generated with locale.library/FormatDate(), so its documentation
applies. The most useful placeholders are repeated here just for user
- %a – abbreviated weekday name (uses current locale)
- %A – weekday name (uses current locale)
- %b – abbreviated month name (uses current locale)
- %B – month name (uses current locale)
- %d – day number with leading 0s
- %D – same as "%m/%d/%y"
- %e – day number with leading spaces
- %h – abbreviated month name (uses current locale)
- %j – julian date
- %m – month number with leading 0s
- %U – week number, taking Sunday as first day of week
- %w – weekday number
- %W – week number, taking Monday as first day of week
- %x – same as "%m/%d/%y"
- %y – year using two digits with leading 0s
- %Y – year using four digits with leading 0s
- PREFIX – Places the date at the start of name instead of the end.
- EXTENSION – Smart inserting at the end. If the file name has an extension (separated by a dot), the date is inserted before extension. If there are multiple dots in the name, the last one is considered as extension separator. Note that this argument is ignored, if PREFIX is specified.
Let's assume today is 2008-06-27.
Append today date with default format to file 'foo'. On my system (country set to Poland) it gives the result "foo_2008-06-27":
Append yesterday date in YYYY-MM-DD format, date is separated by a dot. The result is "foo.2008-06-26":
AppendDate foo DAYS -1 FORMAT ".%Y-%m-%d"
Append just a today weekday name, with fancy separator. The result is "irclog from Friday":
AppendDate irclog FORMAT " from %A"
Append date in the default format as prefix (result is "2008-06-27_foo"):
AppendDate foo PREFIX
Append YYY-MM-DD date to a picture, separated with a dot, preserving extension (result is "picture.2008-06-27.jpg").
AppendDate picture.jpg EXT FORMAT .%Y-%m-%d
- 1.4 (25.12.2012)
- Fixed: EXTENSION does not add stray dot at end when file has no extension.
- 1.3 (03.07.2008)
- Added: EXTENSION and PREFIX arguments.
- Fixed: FormatDate() has been called with NULL locale which resulted in a crash if FORMAT has been used with textual date elements like week or month names.
- 1.2 (27.06.2008)
- Fixed: DAYS argument was ignored if FORMAT was used.