Page 1 of 1

Date Format Change

PostPosted: Tue Aug 16, 2022 3:31 pm
by rehva
I have files like below:
[b]
sw2345_SSM2768-SSMH1055_662022_12345fdr.pdf

I would like to change the date format from 5242022 (day month year) to year month day which would be 20220524.

Re: Date Format Change

PostPosted: Tue Aug 16, 2022 3:38 pm
by rehva
rehva wrote:I have files like below:
[b]
sw2345_SSM2768-SSMH1055_5242022_12345fdr.pdf

I would like to change the date format from 5242022 (day month year) to year month day which would be 20220524.

Re: Date Format Change

PostPosted: Tue Aug 16, 2022 7:31 pm
by therube
Not sure how "5242022" relates to the pdf's filename? Anyhow...

Without seeing sample file names... Would help if we could...

Can the name be 112022 (for 1-1-2022)?
Or 1012022 or 0112022 or 01012022?

So is that 10-1-2022 or 1-01-2022 or 01-1-2022 or ?

Re: Date Format Change

PostPosted: Tue Aug 16, 2022 8:13 pm
by rehva
Here is a filename:

SSGM0021_SSMH1056-SSMH1055_662022_state street.pdf

This file has 662022 as date another file could have 10272022 as date. I need the date to be year month day.

_(m|mm)(d|dd)(20yy)_ ===> _20yymmdd_

PostPosted: Wed Aug 17, 2022 7:40 am
by Luuk
Its unfortunate, but the first post is saying to convert "day month year" ===> "year month day".
But then, the examples present "month day year", so its to be very confusing on how to conduct?
If the dates is always "month day year" and separated by underscores, like inside of the examples?

Then Regex(1) can use a checkmark inside for "v2", so then a "Match" and "Replace" like...
(?<=_)([1-9]\d\d?20\d\d)(?=_)(?X)(?<=_)(\d\d)([1-9]20\d\d)(?=_)(?X)(?<=_)(\d{4})(20\d\d)(?=_)/g
0$1(?X)${1}0$2(?X)$2$1

But if any of the dates are like "day month year", then this will destroy their date-format!

Re: Date Format Change

PostPosted: Wed Aug 17, 2022 6:43 pm
by rehva
Thanks very much for the help. I will test.