Remove double words

Advanced Renamer forum
#1 : 20/03-16 21:54
modman
modman
Posts: 1
Hello

It is possible to remove double words separated by space in file name?

How can i do it?

Example

From: Alfa 145 Alfa Romeo 145 1.3lts M.Marelli 6160029601.std

To: Alfa 145 Romeo 1.3lts M.Marelli 6160029601.std

Thanks


20/03-16 21:54
#2 : 26/03-16 20:56
Kim Jensen
Kim Jensen
Administrator
Posts: 775
Reply to #1:
Unless you can find some other pattern in the filename you can base your naming rules on, I don't think you can do this. Unfortunately.


26/03-16 20:56
#3 : 26/03-16 23:51
Tester123
Tester123
Posts: 92
Reply to #1:
Try this Script Method:

---------- Start of Script ----------
var separator = ' ';
var newFileName;
var currentWord;
var isRepeat;

// Split filename into its constituent words (separated by spaces)
for (j = 0; j < item.name.split(separator).length; j++) {
currentWord = item.name.split(separator)[j];

// Check if the current word is already present earlier
isRepeat = false;
for (k = 0 ; k < j; k++) {
if (item.name.split(separator)[k] == currentWord) {
isRepeat = true;
break;
}
}

// Build new filename by suppressing repeated words
if (!isRepeat) {
if (j == 0)
newFileName = currentWord;
else
newFileName = newFileName + separator + currentWord;
}
}

return newFileName;
---------- End of Script ----------

Unfortunately, the forum doesn't display the indentation levels, so it's harder to read than it should be.


26/03-16 23:51 - edited 26/03-16 23:59