Date & Time Taken Filename

A swapping-ground for Regular Expression syntax

Date & Time Taken Filename

Postby testsubjec » Wed May 20, 2015 12:24 pm

Hi,

I want to quickly rename all my current photos from this format:

"20140721_193006.jpg"

To this format:

"2014-07-21 19.30.06.jpg"

Basically it's the Date (YYYY-MM-DD) & Time (HH.MM.SS) Take Taken attribute of the photo but I cannot figure out who to use BRU to produce this.

Please could someone help.

Thank you!!!
testsubjec
 
Posts: 1
Joined: Wed May 20, 2015 12:19 pm

Re: Date & Time Taken Filename

Postby Stefan » Thu May 21, 2015 6:43 am

 

FROM:
20140721_193006.jpg

TO:
2014-07-21 19.30.06.jpg

RULE:
Separate date tokens with hyphens, time with dot, and also replace the underscore by a space.
So we match 4 digits, 2 digits, 2 digits, underscore, 2 digits, 2 digits, 2 digits.
and add the wanted delimiters our self in replacement string.



USE:
RegEx(1)
Match: (\d\d\d\d)(\d\d)(\d\d)_(\d\d)(\d\d)(\d\d)
or
Match: (\d{4})(\d{2})(\d{2})_(\d{2})(\d{2})(\d{2})


Replace: \1-\2-\3 \4.\5.\6
(Note the space between \3 and \4.)


Explanation:
\1 represent what was matched with first parentheses (...)
\2 represent what was matched with second parentheses (...)
The hyphens, space and the dots are entered literally by hand.

 
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions