Rename DD-MM-YYYY to YYYY-MM-DD

Post any Bulk Rename Command support requirements here. Open to all registered users.

Rename DD-MM-YYYY to YYYY-MM-DD

Postby ryanvo1991 » Tue Jun 16, 2015 5:51 am

Hi all,


I have hundreds of files that I need to change the date format to. They are currently set as DD-MM-YYYY and I need to change them to YYYY-MM-DD


For example I want to change

01-02-2015

TO

2015-02-01

Any help would be appreciated.

Thank you!
ryanvo1991
 
Posts: 2
Joined: Tue Jun 16, 2015 5:26 am

Swap reorder rearrange date time parts DD-MM-YYYY

Postby Stefan » Tue Jun 16, 2015 6:42 am

The solution depends of your whole file name (not only the date part) as BRUs RegEx only work on the whole name.


For just the date part it would be:

FROM/ORIGIN:
DD-MM-YYYY
01-02-2015

TO/WANTED:
YYYY-MM-DD
2015-02-01

use
RegEx(1)
Match: (\d\d)-(\d\d)-(\d\d\d\d)
Repla: \3-\2-\1



EDIT: forgot a hyphen to add.
Last edited by Stefan on Tue Jun 16, 2015 7:19 am, edited 1 time in total.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Rename DD-MM-YYYY to YYYY-MM-DD

Postby ryanvo1991 » Tue Jun 16, 2015 6:50 am

Thank you for your reply!

Each file has a different name though. Different in length. The only part I need to change is the date part of it?

Would this still work?
ryanvo1991
 
Posts: 2
Joined: Tue Jun 16, 2015 5:26 am

Re: Rename DD-MM-YYYY to YYYY-MM-DD

Postby Stefan » Tue Jun 16, 2015 7:18 am

ryanvo1991 wrote:Each file has a different name though. Different in length.

Of course.
But that doesn't matter, as long as you (or we) can find a common pattern.
For example, you could match everything before and after the date by just (.+)(\d\d)-(\d\d)-(\d\d\d\d)(.+)
Only you have to recount the capture groups after that and adjust the replacement too, as here to: \1\4-\3-\2\5

All depends on your real file names.

ryanvo1991 wrote:Would this still work?

No, BRUs RegEx engine works only on the whole file name, not on parts only.
(Example here: http://www.bulkrenameutility.co.uk/forum/viewtopic.php?p=6477#p6477 )

If you don't match and capture the other parts too, you won't have them in the output.



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


Return to BRC Support


cron