Date Format Change

Bulk Rename Utility How-To's

Date Format Change

Postby rehva » Tue Aug 16, 2022 3:31 pm

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.
rehva
 
Posts: 4
Joined: Tue Aug 16, 2022 3:19 pm

Re: Date Format Change

Postby rehva » Tue Aug 16, 2022 3:38 pm

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.
rehva
 
Posts: 4
Joined: Tue Aug 16, 2022 3:19 pm

Re: Date Format Change

Postby therube » Tue Aug 16, 2022 7:31 pm

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 ?
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Date Format Change

Postby rehva » Tue Aug 16, 2022 8:13 pm

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.
rehva
 
Posts: 4
Joined: Tue Aug 16, 2022 3:19 pm

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

Postby Luuk » Wed Aug 17, 2022 7:40 am

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!
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm

Re: Date Format Change

Postby rehva » Wed Aug 17, 2022 6:43 pm

Thanks very much for the help. I will test.
rehva
 
Posts: 4
Joined: Tue Aug 16, 2022 3:19 pm


Return to How-To