Tips & Tricks: File Renaming and Date Format

One of the great actions that Action(s) provides is the Rename Files action.


Especially, using the add date mode, you can add a date to the file name using various date formats. By default, Rename Files provides 7 formats:

Date and Time Format Example
dd MMMMM yyyy 29 March 2011
dd-MM-yy 29-03-11
MM-dd-yy 03-29-11
yyyyMMdd 20110329
dd-MM-yy hh.mm.ss 29-03-11 17.42.12
h.mm a 5.42 pm
hh.mm 17.42


But you can also create your own format if the ones provided does not answer your need. It is very easy. Action(s) interprets different letters as date and time codes and replaces them by their values. You can combine the codes to create your own format.
Here are the available iddentifiers:

Code Date or Time Component Examples
G Era designator AD
yy Year (2 digits) 96
yyyy Year (4 digits) 1996
MM Month in year (2 digits) 07
MMM Month in year (3 letters) Jul
MMMM Month in year (full) July
w Week in year 27
W Week in month 2
D Day in year 189
d Day in month (1 or 2 digits) 5 ; 23
dd Day in month (2 digits) 05 ; 23
F Day of week in month 2
EEE Day in week (3 letters) Tue
EEEE Day in week (full) Tuesday
a Am/pm marker PM
H Hour in day (0-23) (1 or 2 digits) 0 ; 14
HH Hour in day (0-23) (2 digits) 00 ; 14
h Hour in am/pm (1-12) (1 or 2 digits) 12 ; 3
hh Hour in am/pm (1-12) (2 digits) 12 ; 03
k Hour in day (1-24) (1 or 2 digits) 24 ; 3
kk Hour in day (1-24) (2 digits) 24 ; 03
K Hour in am/pm (0-11) (1 or 2 digits) 0 ; 11
K Hour in am/pm (0-11) (2 digits) 00 ; 11
m Minute in hour (1 or 2 digits) 30 ; 5
mm Minute in hour (2 digits) 30 ; 05
s Second in minute (1 or 2 digits) 55 ; 8
ss Second in minute (2 digits) 55 ; 08
S Millisecond (1, 2 or 3 digits) 978 ; 78 ; 9
SSS Millisecond (3 digits) 978 ; 078 ; 009
zzz Time zone (short name if available or GMT based) PST ; GMT-08:00
zzzz Time zone (full name if available or GMT based) Pacific Standard Time ; GMT-08:00
Z Time zone (RFC 822 format) -0800


Text can be quoted using single quotes (') to avoid interpretation. '' (2 quotes) represents a single quote.
All characters which are not letters (from 'A' to 'Z' and from 'a' to 'z') are not interpreted and so do not need to be put between quotes.

The following examples show how date and time patterns are interpreted in the U.S. locale. The given date and time are 4 July 2001 at 12:08:56 local time in the U.S. Pacific Time time zone.

Date and Time Format Result
yyyy.MM.dd G 'at' HH:mm:ss z 2001.07.04 AD at 12:08:56 PDT
EEE, MMM d, ''yy Wed, Jul 4, '01
h:mm a 12:08 PM
hh 'o''clock' a, zzzz 12 o'clock PM, Pacific Daylight Time
K:mm a, z 0:08 PM, PDT
yyyy.MMMM.dd GGG hh:mm aaa 2001.July.04 AD 12:08 PM
EEE, d MMM yyyy HH:mm:ss Z Wed, 4 Jul 2001 12:08:56 -0700
yyMMddHHmmssZ 010704120856-0700


blog comments powered by Disqus