#1 2013-12-28 10:22

kaja69
Member
Registered: 2013-12-28
Posts: 4

Rename to US date format for correct sorting

I have many foto files named after Danish date/time conversion eg. "31-03-2013 19-52-16.jpg". Can I use ReNamer to change to eg. "2013-03-31 19-52-16.jpg" so files will sort corretly? If I have to create a rearrange rule what should it look like? Thanks for any help!

Offline

#2 2013-12-28 13:26

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,479

Re: Rename to US date format for correct sorting

This will do it using Rearrange rule:

Rearrange: Split by exact pattern of delimiters "-", "-", " ", New pattern "$3-$2-$1 $4" (skip extension)

However, it will also rearrange filenames which happen to have two dashes and a space, for example "this-is-example of filename".

It is better to use RegEx rule like so:

RegEx: Replace expression "\b(\d{2})-(\d{2})-(\d{4})\b" with "$3-$2-$1" (skip extension)

This will find dates exactly in XX-XX-XXXX format anywhere in the file and rearrange them as you need.

Offline

#3 2013-12-28 13:37

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Rename to US date format for correct sorting

Hi kaja, welcome.

You could utilize the Rearrange rule > http://www.den4b.com/wiki/ReNamer:Rules:Rearrange

Your delimiter would be "-" and " ".
So add "-| " into the delimiter field and choose "(o)Delimiters".

In the "New pattern" field you can use $1 till $6 to compose your new name.
For an test, which parts that will get you, add "$1=$2=$3=$4=$5=$6" into the "New pattern" field.
That will gave you "31=03=2013=19=52=16.jpg" in the preview (Tip: utilize "Options > Analyse sample test" for testing)

Now you can rearrange these $n pattern and adjust the delimiters to get what you wanted:> "$3-$2-$1 $4-$5-$6"
And you will get >>> "2013-03-31 19-52-16.jpg"

- - -

Another possibility would be to utilize regular expressions > http://www.den4b.com/wiki/ReNamer:Rules:RegEx

Expression: "(\d\d)-(\d\d)-(\d\d\d\d) (.+)"
Replace: "$3-$2-$1 $4"


That will match and store two digits, dash, two digits, dash, four digits, an blank and then the rest.
In the replace field you simply rearrange what you have captured in the (...) parentheses, by utilizing the $n signs.


HTH?

Last edited by Stefan (2013-12-28 13:38)


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#4 2013-12-28 20:26

kaja69
Member
Registered: 2013-12-28
Posts: 4

Re: Rename to US date format for correct sorting

RegEx worked great. Thank you very much!

Offline

Board footer

Powered by FluxBB