#1 2020-05-17 23:10

Karleesi
Member
Registered: 2020-05-08
Posts: 34

Change format and position of date

Hello guys,

I have a lot of folders named like this:
AAA Hello There 12-31-2020 Part
ZZZZZZ Good Bye 09-25-1999 Part

The date is always mm-dd-yyyy.

And I would like to have them like this:
AAA 2020.12.31 Hello There Part
ZZZZZZ 1999.09.25 Good Bye Part



So that the files due to my current rules setup look like this:
AAA.2020.12.31.Hello.There.Part.1.jpg
AAA.2020.12.31.Hello.There.Part.2.jpg
...
ZZZZZZ.1999.09.25.Good.Bye.Part.1.jpg
ZZZZZZ.1999.09.25.Good.Bye.Part.2.jpg
...

In other words:
Is it possible to change the format of the date AND move it right to the position where the first words "ends". So right After AAA or a longer word like ZZZZZZ?

Here is my current preset:
1) Delete: Delete current name (skip extension)
2) Insert: Insert ":File_FolderName:" as Prefix (skip extension)
3) Serialize: Incremental from 1 repeat 1 step 1 (reset index if folder changes) and pad to length 1 as Suffix (skip extension)
4) Replace: Replace all "Part" with "Part.", "Disc" with "Disc.", " " with "."
5) Pascal Script: const FileMask = '*'; StripChars = '_0123456789'; var Files: TWideStringArray; begin SetLength(Files, 0); WideScanDirForFiles(WideExtractFileDir(FilePath), Files, False, False, False, FileMask); if Length(Files) = 1 then begin FileName := WideExtractFilePath(FileName) + WideTrimCharsRight(WideExtractBaseName(FileName), StripChars) + WideExtractFileExt(FileName); end; end.
6) Remove: Remove all "~" (skip extension)

Thanks for everything, this program is amazing and can't imagine working without it anymore.

Last edited by Karleesi (2020-05-17 23:12)

Offline

#2 2020-05-18 07:25

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Change format and position of date

Hi,

>>"Is it possible to change the format of the date AND move it right to the position where the first words "ends""
Yes, no problem.

We can do that by RegEx
https://www.den4b.com/wiki/ReNamer:Rules:RegEx

Maybe with help by using ReformatDate first
https://www.den4b.com/wiki/ReNamer:Rules:ReformatDate

But I don't understand what you want exactly? .... folders? .... files?
For me it looks like you want to rename the folders first, and afterwards the files with the folder name?
Please clarify.


 


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#3 2020-05-18 08:42

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

Re: Change format and position of date

The reformatting of dates can be achieved by either the Regular Expressions or the Reformat Date rule, but the operation for moving the date to a different position is best accomplished by the Regular Expressions rule alone.

For the sake of a demonstration, I will show how to do these operations with two rules:

1) Reformat Date: Convert to "yyyy.mm.dd" from "mm-dd-yyyy", whole words only
2) Regular Expressions: Replace expression "\A(\w+)\b(.+)\b(\d{4}\.\d{2}\.\d{2})\b\s*" with "$1 $3$2"

Note that the "skip extension" option should be disabled in both rules.

Input names:

AAA Hello There 12-31-2020 Part
ZZZZZZ Good Bye 09-25-1999 Part

Output names:

AAA 2020.12.31 Hello There Part
ZZZZZZ 1999.09.25 Good Bye Part

Offline

#4 2020-05-18 08:44

Karleesi
Member
Registered: 2020-05-08
Posts: 34

Re: Change format and position of date

Hi Stefan, thanks for your reply!
The files in the folders are a mess. I usually rename the folders manually (most of it) and the files "become" the parent folder and get numbered. That's how I do it at the moment. You can see that in the presets/rules. So the "only" thing I need is that the format of the date gets changed and moves to the first "gap"/space after the first word, see example.
Thanks again.

Offline

#5 2020-05-18 09:33

Karleesi
Member
Registered: 2020-05-08
Posts: 34

Re: Change format and position of date

den4b wrote:

The reformatting of dates can be achieved by either the Regular Expressions or the Reformat Date rule, but the operation for moving the date to a different position is best accomplished by the Regular Expressions rule alone.

For the sake of a demonstration, I will show how to do these operations with two rules:

1) Reformat Date: Convert to "yyyy.mm.dd" from "mm-dd-yyyy", whole words only
2) Regular Expressions: Replace expression "\A(\w+)\b(.+)\b(\d{4}\.\d{2}\.\d{2})\b\s*" with "$1 $3$2"

Note that the "skip extension" option should be disabled in both rules.

Input names:

AAA Hello There 12-31-2020 Part
ZZZZZZ Good Bye 09-25-1999 Part

Output names:

AAA 2020.12.31 Hello There Part
ZZZZZZ 1999.09.25 Good Bye Part

Wow, thank you! Will try it as soon as I get home. So the expression gets also moved to the position like you said? Awesome! Thanks again!

Offline

#6 2020-05-18 11:43

Karleesi
Member
Registered: 2020-05-08
Posts: 34

Re: Change format and position of date

THANK YOU!
foldernew.jpg

Just a minor thing I think: Why are there 2 dots ".." after "Toll"? Could you help me again, please? We're almost there! smile

Offline

#7 2020-05-18 11:51

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Change format and position of date

Karleesi wrote:

Just a minor thing I think: Why are there 2 dots ".." after "Toll"?

Perhaps from your rule No 4 ?
Probably your folder name contains already an dot? We don't see from where that "Ich bin so toll" comes from.

To test, temporally change  <Replace " " by ".">  by  <Replace " " by "#"> or something like that.





 


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#8 2020-05-18 13:05

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

Re: Change format and position of date

Karleesi wrote:

Why are there 2 dots ".." after "Toll"?

The double dots are just a result of rearranging parts with the Regular Expressions rule. The previously posted rules were created for the original examples where spaces were used in-place of dots, but it is easy to change the rules to handle both spaces and dots.

Updated rules:

1) Reformat Date: Convert to "yyyy.mm.dd" from "mm-dd-yyyy", whole words only
2) Regular Expressions: Replace expression "\A(\w+)\b(.+)\b(\d{4}\.\d{2}\.\d{2})\b[\s\.]*" with "$1.$3$2"

Offline

#9 2020-05-18 14:37

Karleesi
Member
Registered: 2020-05-08
Posts: 34

Re: Change format and position of date

I'm sorry. (edit)

Last edited by Karleesi (2020-05-18 15:30)

Offline

#10 2020-05-18 15:16

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

Re: Change format and position of date

Karleesi wrote:

8) Regular Expressions: Replace expression "\A(\w+)\b(.+)\b(\d{4}\.\d{2}\.\d{2})\b[\s\.]*" with "1.$3$2"

Your configuration of the Regular Expressions rule is wrong. You missed a dollar sign.

It should be as follows:

den4b wrote:

Regular Expressions: Replace expression "\A(\w+)\b(.+)\b(\d{4}\.\d{2}\.\d{2})\b[\s\.]*" with "$1.$3$2"

Offline

Board footer

Powered by FluxBB