Changing YYMMDD to YYYY-MM-DD

A swapping-ground for Regular Expression syntax

Changing YYMMDD to YYYY-MM-DD

Postby stst415 » Mon Aug 12, 2013 3:31 pm

First, this program is incredible! It's finally standardizing SO many incongruous file names. THANK YOU to its developers.

I do, though, have a more complex problem that I need help with....

My file names already have the dates built into them as YYMMDD, but I want to change them all to YYYY-MM-DD. Here are some quick examples:

SantaMonicaPier_051213_STST_001.jpg -----> SantaMonicaPier_2005-12-13_STST_001.jpg
GoldenGateBridge_100409_STST_001.jpg -----> GoldenGateBridge_2010-04-09_STST_001.jpg
BeverlyHills90210_130415_STST_001.jpg -----> BeverlyHills90210_2013-04-15_STST_001.jpg
Yosemite_000630_STST_001.jpg -----> Yosemite_2000-06-30_STST_001.jpg

There are often numbers throughout, but the dates are ALWAYS six digits and with an underscore on either side. -----> _130812_

I don't want to pull any data from the EXIF. The new file names should solely be based on the old ones.

Let's assume that there are no dates from the 1900s (I'll deal with them separately). All NEW dates will begin with "20".

What do you recommend?

Thanks!
Scott
stst415
 
Posts: 2
Joined: Mon Aug 12, 2013 2:42 pm

Re: Changing YYMMDD to YYYY-MM-DD

Postby stst415 » Mon Aug 12, 2013 6:10 pm

I think I figured out an expression that seems to work!

MATCH: ^(.*)_([0-9]{2})([0-1][0-9])([0-3][0-9])(.*)
REPLACE: \1_20\2-\3-\4\5

Before I commit to doing half a million files, is there a better way?

Scott
stst415
 
Posts: 2
Joined: Mon Aug 12, 2013 2:42 pm

Re: Changing YYMMDD to YYYY-MM-DD

Postby Admin » Mon Aug 12, 2013 11:39 pm

You could use \d as an alternative which matches a digit, e.g. ^(.*)_(\d\d)(\d\d)(\d\d)_(.*) , but your expression is more restrictive.
Admin
Site Admin
 
Posts: 2351
Joined: Tue Mar 08, 2005 8:39 pm

Re: Changing YYMMDD to YYYY-MM-DD

Postby Stefan » Tue Aug 13, 2013 9:50 am

stst415 wrote:Before I commit to doing half a million files, is there a better way?
Do a backup first.







Server too busy... please wait a few seconds then try re-submitting. Thank you
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Changing YYMMDD to YYYY-MM-DD

Postby Admin » Tue Aug 13, 2013 12:44 pm

Stephan, regarding the message "Server too busy... please wait a few seconds then try re-submitting. Thank you"... that is a forum SPAM prevention measure: the message is given when messages are submitted too fast (often in an automated mode). thanks
Admin
Site Admin
 
Posts: 2351
Joined: Tue Mar 08, 2005 8:39 pm

Re: Changing YYMMDD to YYYY-MM-DD

Postby Stefan » Tue Aug 13, 2013 9:55 pm

Admin wrote:.. please wait a few seconds then try re-submitting.
I will do. But often I had to wait days (whole weekend) and at the end I still can't post. Had to post from work pc then.
Got that often in the last weeks (writing a answers, and then can't post it)

Well, will see how its works the next weeks. In the last days I saw that message only once, then I could post. But I see that too often.






Server too busy... please wait a few seconds then try re-submitting. Thank you
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Changing YYMMDD to YYYY-MM-DD

Postby Admin » Wed Aug 14, 2013 1:45 am

I have removed the "Server too busy" protection now, I think it's no longer required to control SPAM- thanks
Admin
Site Admin
 
Posts: 2351
Joined: Tue Mar 08, 2005 8:39 pm


Return to Regular Expressions