#1 2009-05-10 17:10

Alan
Member
Registered: 2009-05-10
Posts: 3

Moving and reformatting date in filename

Please could someone tell me what I must do to rename files I have saved as: A N Other ddmmyy;  to be renamed: yyyymmddOtherAN.

I am sorry if this question has been asked before.  While I can use a computer, I don't know how to write strings etc.

I would welcome any help.

Many thanks.

Offline

#2 2009-05-10 21:16

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: Moving and reformatting date in filename

Before somebody chimes in with a solution using RegEx, I'd just like to ask, do you want all 2-digit years to be treated as belonging to the current century (2000s) while converting to 4-digit years?

Offline

#3 2009-05-11 08:29

krtek
Senior Member
From: Łódź (Poland)
Registered: 2008-02-21
Posts: 262

Re: Moving and reformatting date in filename

Regex rule:
expression: ^(\w)\s(\w)\s(.+)\s(\d{2})(\d{2})(\d{2})$
replace: 20$6$5$4$3$1$2

If it is not the current century, please change 20 to 19 in replace part.


Regular Expressions are not as hard to understand as you may think. Check ReNamer's manual or nice Regular Expressions tutorial for more info and start to use full power of applications that use them (like ReNamer, Mp3Tag and so on).

Offline

#4 2009-05-12 06:56

Alan
Member
Registered: 2009-05-10
Posts: 3

Re: Moving and reformatting date in filename

Thank you krtek and Andrew for your replies.

To respond to Andrew's point.  No, I want the years to remain the same as when the file was created, but converted to four digit years - so a file created on 10th May 1998 and named A N Other 100598 will be renamed 1998051OtherAN; and likewiseone one created on 10th May 2003 will be renamed 20030510OtherAN.

Many thanks for your help.

Offline

#5 2009-05-12 11:11

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

Re: Moving and reformatting date in filename

Because some years need to be padded with "20" and some with "19" you need to define basis upon which to decide which years should be converted to which century.

If we assume that all years with the second order digit being 0..1 (e.g. 2009, 2010) should be padded with "20" and the rest with second order digits 2..9 (e.g. 1998, 1970) should be padded with "19", we can use 2 RegEx rules with the following parameters.

Expression: ^(.*)(\d{2})(\d{2})([0-1]\d)$
Replace: 20$4$3$2 $1

Expression: ^(.*)(\d{2})(\d{2})([2-9]\d)$
Replace: 19$4$3$2 $1

Very similar to what krtek have suggested. The last thing you'll have to do is simply strip out the spaces, with Remove rule for example.

Offline

#6 2009-05-13 17:32

Alan
Member
Registered: 2009-05-10
Posts: 3

Re: Moving and reformatting date in filename

At last I've had time to sit down and play with Renamer.

Many thanks to those who answered my plea for help: Andrew; krtek and den4b.

Your suggestions worked, although not in quite the way I expected, but in a good enough and, perhaps, an even better way.

As I said in my initial request for help, I know nothing about these expressions; they are literally a foreign language to me.  So again guys, many thanks for your help.

Offline

Board footer

Powered by FluxBB