Remove duplicate phrases

Advanced Renamer forum
#1 : 25/04-24 10:30
Nemo
Nemo
Posts: 2
I am looking for a way to remove duplicate phrases, specifically dates in this format:

Letter 2 May 2013 2 May 2013

This old post https://www.advancedrenamer.com/forum_thread?for um_id=3052

gives a simple method for removing duplicates phrases. Replace (.+)\1 with \1

However I need a method which only affects phrases of a minimum length.

The method described would, for example, cause

IMG_0362 2 May 2013 to be renamed to IMG_0362 May 2013 which is not want a want.


25/04-24 10:30
#2 : 25/04-24 11:56
Delta Foxtrot
Delta Foxtrot
Posts: 111
Reply to #1:

Hi Nemo,

This may or may not work for you, depending on how regular your filenames are. It works for me on the limited examples you gave, but for future reference always try to give as much information as you can about the problem, like for instance a representative sample of the types of filenames you are struggling with. If this works, great; if not, let me know (with more examples) and we'll try to help you. I'll tell you now that this will only work if there's one "word" before the first date, and it's in the format you entered.

Oh, I suggest you copy/paste the expressions, because you left out a space in the formula you entered from the previous thread. It didn't work on your problem anyway, but...

Replace method:
Text to replace: "^\w+\b \K(\d{1,2} [a-z]+ \d\d\d\d) \1" (without the quotation marks)
Replace with: \1 (no spaces)
All occurrences
Regular expressions: YES
Apply to: Name

Good luck!
DF


25/04-24 11:56
#3 : 25/04-24 16:01
Nemo
Nemo
Posts: 2
Reply to #2:

Hi

The distinction between what needs to be removed and what shouldn't be is intuitive and rather hard to formularise but I ended up using this:

Replace method:
Text to replace: "(..........+) \1" (without the quotation marks)
Replace with: \1 (no spaces)
All occurrences
Regular expressions: YES
Apply to: Name

But thanks for your suggestion.

N


25/04-24 16:01
#4 : 25/04-24 21:47
Delta Foxtrot
Delta Foxtrot
Posts: 111
Reply to #3:

Whoa, that's a lot of dots. "That's not a period, that's a linear exclamation mark!" :)

(..+) \1 seems to do the same thing, at least in your examples.

That's cool, though, I wouldn't have thought that would work... good to learn!



25/04-24 21:47