Song title repeats in filename

Advanced Renamer forum
#1 : 31/01-19 20:17
Matt Rascon
Matt Rascon
Posts: 1
I have a set of albums in which the title for each track is repeated three times in the filename. I want to rename these files (about 100) with the title given only once.
EXAMPLE:

Killing FieldKilling FieldKilling Field --> Killing Field
Baby BabyBaby BabyBaby Baby --> Baby Baby

Is this possible to do in a batch?


31/01-19 20:17 - edited 31/01-19 20:27
#2 : 31/01-19 22:58
David Lee
David Lee
Posts: 153
Reply to #1:
If your examples represent the entire filenames then you could use this script:

name = item.name;
return name.slice(0, name.length/3);


31/01-19 22:58
#3 : 15/02-19 11:46
_H_
_H_
Posts: 8


15/02-19 11:46
#4 : 15/02-19 13:14
David Lee
David Lee
Posts: 153
Reply to #3:
Your RegEx leaves TWO spaces between the component words of the filename.
You need to match the leading space in BOTH sub patterns:

(\h\w+)(\1)

A simpler regular expression would be:

\w+ \w+

which matches two "words" each beginning with a space (note there is a space before each "\w")

However, either of these solutions assume that the filenames always comprise the repetition of exactly two words separated by a space. Otherwise the script to extract just the first third of the original filename will be more general.


15/02-19 13:14 - edited 15/02-19 13:30