#11 2020-05-18 15:42

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

Re: Change format and position of date

Oh my, I'm sorry! It works... You've done an awesome job once again. Thanks for everything.

Offline

#12 2020-05-21 22:05

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

Re: Change format and position of date

Hey, a little follow up question.
I also have folders like this: Shooto To The Top 4 05-01-2001 (05-17-2001). I'd also like to reformat the date in (...) but without moving it to the front like the other date. That's why added another rule: Rule number 8.

1) Delete: Delete current name (skip extension)
2) Insert: Insert ":File_FolderName:" as Prefix (skip extension)
3) Insert: Insert "~" as Suffix (skip extension)
4) Serialize: Incremental from 1 repeat 1 step 1 (reset index if folder changes) and pad to length 1 as Suffix (skip extension)
5) Replace: Replace all "Part" with "Part.", "Disc" with "Disc.", " " with "."
6) 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.
7) Remove: Remove all "~", ")", "(" (skip extension)
8) Reformat Date: Convert to "yyyy.mm.dd" from "(mm-dd-yyyy)", whole words only
9) Reformat Date: Convert to "yyyy.mm.dd" from "mm-dd-yyyy", whole words only
10) Regular Expressions: Replace expression "\A(\w+)\b(.+)\b(\d{4}\.\d{2}\.\d{2})\b[\s\.]*" with "$1.$3$2"

Is it possible that the date of rule #8 doesn't get moved around. I mean, that the position of the date in (...) doesn't change? FIle should become: Shooto.2001.05.01.To.The.Top.4.2001.05.17
Thanks.

Last edited by Karleesi (2020-05-21 22:06)

Offline

#13 2020-05-21 22:28

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

Re: Change format and position of date

Your rule #8 doesn't actually do anything. The "(mm-dd-yyyy)" format will never be found, because you removed all round brackets in rule #7.

What you really need to do is to make a microscopic adjustment to the Regular Expression rule, so that it will stop searching after it finds the very first date.

The updated rule:

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

Note the extra "?" meta character. It changes the search mode prior to the date pattern to a non-greedy mode.

It might be time for you to start learning the Regular Expressions:
https://www.den4b.com/wiki/ReNamer:Regular_Expressions

Offline

#14 2020-05-23 15:46

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

Re: Change format and position of date

Thank you. I read it and it all sounds crazy to me. I'm not familiar with coding and that things. I really try to get into that and help myself but it is really hard if you have never done such things. So, sorry for asking and sorry if I bothered you. sad

You wrote the code, that the date gets move to he beginning, right after the first word. It's great but it doesn't work with words like double nouns, for example Anna-Nicole. Date gets moved right after Anna. Is there a way to handle words like these as 1 word so the date gets moved right after Anna-Nicole, for example? Thanks.

Current presets:
1) Delete: Delete current name (skip extension)
2) Insert: Insert ":File_FolderName:" as Prefix (skip extension)
3) Insert: Insert "~" as Suffix (skip extension)
4) Serialize: Incremental from 1 repeat 1 step 1 (reset index if folder changes) and pad to length 1 as Suffix (skip extension)
5) Replace: Replace all "Part" with "Part.", "Disc" with "Disc.", " " with "."
6) 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.
7) Remove: Remove all "~", ")", "(" (skip extension)
8) Reformat Date: Convert to "yyyy.mm.dd" from "mm-dd-yyyy", whole words only
9) Regular Expressions: Replace expression "\A(\w+)\b(.+?)\b(\d{4}\.\d{2}\.\d{2})\b[\s\.]*" with "$1.$3$2"

Last edited by Karleesi (2020-05-23 16:18)

Offline

#15 2020-05-23 18:46

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

Re: Change format and position of date

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


The part "\A(\w+)\b" means:

search at
\A
>>>means "start of text (^ is an alternative)".

for
\w
>>>means "an alphanumeric character, including an underscore (_)".
Which match [a-zA-Z0-9_] , means a,b,c,d...A,B,C,D,...0,1,2,3 and underscore  (but NOT hyphen "-")

+
>>>means "one or more" of the expression right before.

(...)
>>>means here to store what is matched by "\w+" for later reuse , here by $1-sign, because its the first ().

\b
>>> means "word boundary" , at begin or at end of an word, next to an white space.


- - -

For you:


\w|-
To match now an hyphen TOO, you have to search for "\w" __or__ "-"

(\w|-)+
For to match "one or more +" of ____"\w"__or__"-" ____, you have to put that inside
another parentheses (...), which means here just "group things together"

(\w|-)*
Because there is not always an hyphen, we search better "ZERO or more *" , instead of "ONE or more +" .

((\w|-)*)
Since we want to store that for later reuse, put that inside another parentheses.

So try this regex:
9) Regular Expressions: Replace expression "\A((\w|-)*)\b(.+?)\b(\d{4}\.\d{2}\.\d{2})\b[\s\.]*" with "$1.$3$2"
EDIT: the line above is wrong, use the line below:
9) Regular Expressions: Replace expression "\A([\w-]*)\b(.+?)\b(\d{4}\.\d{2}\.\d{2})\b[\s\.]*" with "$1.$3$2"

I am hoping I didn't mess things up here, since I have not tested it right now :-(



 

Last edited by Stefan (2020-05-23 21:50)


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

#16 2020-05-23 19:20

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

Re: Change format and position of date

Hi Stefan, thanks for your help and the great explanation. Unfortunately it didn't work. I tried: "\A((\w|-)*)\b(.+?)\b(\d{4}\.\d{2}\.\d{2})\b[\s\.]*" with "$1.$3$2"

Last edited by Karleesi (2020-05-23 19:21)

Offline

#17 2020-05-23 20:35

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

Re: Change format and position of date

WHAT didn't work?
Nothing? Wrong result? ...?

Can you please give us some name after step 8) "Reformat Date"
and how it should look afterwards, after step 9) "Regular Expressions".

Therefore disable rule 9, press Preview for rule 1-8, and see "Export > Export new names to clipboard"


Then we can test on that examples and provide you an solution.


 


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

#18 2020-05-23 20:45

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

Re: Change format and position of date

Sorry for the short answer. I tried it with "Stefan-Steffi Testshow 05-05-2020" which should turn into Stefan-Steffi.2020.05.05.Testshow

It turns out as Stefan.2020.05.05-Steffi.Testshow with all 9 rules and not using your suggestion.

Using your suggestion it turns out like this with all 9 rules: Stefan-Steffi..Testshow
Leaving out rule #9 and using your suggestion it is: Stefan-Steffi.Testshow.2020.05.05

Thanks for your help.

Offline

#19 2020-05-23 21:32

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

Re: Change format and position of date

Sorry, it seams I mixed-up the syntax, try this:


FROM:
Stefan-Steffi.Testshow.2020.05.05
Karleesi.Testshow.2019.04.04

TO:
Stefan-Steffi.2020.05.05.Testshow
Karleesi.2019.04.04.Testshow

Use RegEx:
\A([\w-]+)\b(.*?)\.(\d{4}\.\d{2}\.\d{2})\b[\s\.]*
$1.$3$2
Do not skip extension! as the last .05 is seen as extension.

- - -

Explanations:

\A([\w-]+)\b >>> match first word, chars, numbers, underscore or hyphen till word boundary.
(.*?)\. >>>>>>> match second word, any sign none-or-more non-greedy till word boundary dot.
(\d{4}\.\d{2}\.\d{2})\b >>> match 4 digits, dot, 2 digits, dot 2 digits till word boundary.
[\s\.]* >>> match trailing white space or dot, none-or-more if any.

I had to change second "\b" to "\." as word boundary, else the real dot is matched too in $2 and moved to the end.

Hope that work better.


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

#20 2020-05-23 21:38

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

Re: Change format and position of date

Please don't say "sorry", you're helping me all the time. Thanks, it turns out like this:
Stefan-Steffi.2020.05.05.Testshowjpg
"skip extension" is still unchecked like you told me. Any idea? Almost there! big_smile

Offline

Board footer

Powered by FluxBB