Removing Repeated Words in File Names

Javascript renaming examples. Javascript renaming is supported in version 3 or newer.

Removing Repeated Words in File Names

Postby chrisjg » Wed Jan 22, 2020 12:28 pm

Hi,

I thought this might be a simple, common problem but I've tried searching the forums here and looked at previous posts using google but can't seem to find an answer that helps me.
I have a library of thousands of music files and their corresponding stems some of which have repeated words in their file name.
How can I use BRU to remove anything that is a repeated word in the file name?

Before:
tr43-Apocalyptic_Dreams_Stem1_Drums_Stem1_Drums.aiff
tr44-Apocalyptic_Dreams_Stem2_Choir_Stem2_Choir.aiff
tr45-Apocalyptic_Dreams_Stem3_Percussion_Stem3_Percussion.aiff
tr46-Apocalyptic_Dreams_Stem4_Strings_Brass_Stem4_Strings_Brass.aiff
tr133-Apocalyptic_Dreams_30_Second_30_Second.aiff

After:
tr43-Apocalyptic_Dreams_Stem1_Drums.aiff
tr44-Apocalyptic_Dreams_Stem2_Choir.aiff
tr45-Apocalyptic_Dreams_Stem3_Percussion.aiff
tr46-Apocalyptic_Dreams_Stem4_Strings_Brass.aiff
tr133-Apocalyptic_Dreams_30_Second.aiff

TIA
:)
chrisjg
 
Posts: 7
Joined: Wed Jan 22, 2020 12:18 pm

Re: Removing Repeated Words

Postby therube » Thu Jan 23, 2020 3:35 am

As a start, see what you can make of, Batch remove duplicated word in folder/filename? (though I'm not sure offhand if something like that will handle your situation, but it's a start...).
therube
 
Posts: 889
Joined: Mon Jan 18, 2016 6:23 pm

Re: Removing Repeated Words

Postby chrisjg » Thu Jan 23, 2020 7:06 am

Hi, thank you!
I did try to follow this thread a couple of times yesterday and made several attempts at applying it to my scenario but without much luck. Further to that is I'm currently not under a commercial license for BRU so I'm unable to utilise the java script options.

I figured there must be a simpler method of removing repeated words from a filename by just using BRU out of the box since there's so many useful functions already at my disposal, I'm just not smart enough to figure it out. :wink:
chrisjg
 
Posts: 7
Joined: Wed Jan 22, 2020 12:18 pm

Re: Removing Repeated Words

Postby Admin » Fri Jan 24, 2020 12:05 am

Can be done in Javascript in this way:

- split name in multiple words (separated by _)
- rebuild the name using the same words, use _ as separator, do not add a word if duplicate.
Admin
Site Admin
 
Posts: 1848
Joined: Tue Mar 08, 2005 8:39 pm

Re: Removing Repeated Words

Postby chrisjg » Fri Jan 24, 2020 7:12 am

Thanks but I don't really understand any of that.

Sorry if I'm a bit of a newbie here but I am not that familiar with Java script and I don't have the commercial licence for BRU.
chrisjg
 
Posts: 7
Joined: Wed Jan 22, 2020 12:18 pm

Re: Removing Repeated Words

Postby chrisjg » Fri Jan 24, 2020 8:09 am

What I mean is that I understand what you mean, as in delete file name and rebuild it just without the duplicated words, but could you explain the steps a little further for someone that doesn't know Java script?
chrisjg
 
Posts: 7
Joined: Wed Jan 22, 2020 12:18 pm

Re: Removing Repeated Words

Postby Admin » Fri Jan 24, 2020 8:16 am

Hi, we can post the script but you need a commercial license for using JavaScript in BRU, sorry.
Admin
Site Admin
 
Posts: 1848
Joined: Tue Mar 08, 2005 8:39 pm

Re: Removing Repeated Words

Postby chrisjg » Fri Jan 24, 2020 8:32 am

Okay no worries, I'll purchase a commercial licence today.
chrisjg
 
Posts: 7
Joined: Wed Jan 22, 2020 12:18 pm

Re: Removing Repeated Words

Postby Admin » Tue Jan 28, 2020 1:03 am

thanks If you have a commercial licenses we can post a script for this functionality
Admin
Site Admin
 
Posts: 1848
Joined: Tue Mar 08, 2005 8:39 pm

Re: Removing Repeated Words

Postby chrisjg » Tue Jan 28, 2020 11:03 am

Thanks but I actually decided to do it all manually.
I realise I can't afford a license right now as I'm working freelance so instead I just spent most of the last few days doing it all manually. I even tried to see if there was a way to filter all the files that appeared to have duplicate words in their file name to help speed things up a bit but I couldn't work that out either so I just decided to spend several hours doing each file individually.
chrisjg
 
Posts: 7
Joined: Wed Jan 22, 2020 12:18 pm

Re: Removing Repeated Words

Postby Admin » Tue Jan 28, 2020 1:40 pm

Hi, no worries, we wrote the script anyway:

Code: Select all
newName=name.split('_').filter(function(item,i,allItems){
    return i==allItems.indexOf(item);
}).join('_');
Admin
Site Admin
 
Posts: 1848
Joined: Tue Mar 08, 2005 8:39 pm

Re: Removing Repeated Words

Postby chrisjg » Tue Jan 28, 2020 2:03 pm

Thanks.
I don't really know how someone like me would ever know how to do that without spending my time trying to learn programming language first.

I get you need to make money from the software somehow but it's a shame that I can't perform a one time basic function, which is for personal use, without first buying a commercial license. Otherwise I bloody love the software, I'm just not smart enough to use it to it's fully potential.
chrisjg
 
Posts: 7
Joined: Wed Jan 22, 2020 12:18 pm

Re: Removing Repeated Words

Postby Admin » Tue Jan 28, 2020 2:07 pm

Please email support, thanks
Admin
Site Admin
 
Posts: 1848
Joined: Tue Mar 08, 2005 8:39 pm

Re: Removing Repeated Words in File Names

Postby bru » Sat Feb 01, 2020 7:55 am

Sorry, I would have posted a regex solution, but figured you wanted the javascript answer.
I was curious for the answer, so I came back to see it.

For any regexers out there:
(.*)(_[^_]{2,})(_.*)\2(.*)
\1\2\3\4

Each BRU-run removes only 1 repeated 'word' of 2-or-more chars, seperated by _
You can also run BRC-equivalents to remove more occurences per run:
brc32 /Pattern:*_*.aiff /NoFolders /NoDup /Regexp:"(.*)(_[^_]{2,})(_.*)\2(.*):\1\2\3\4" /Regexp:"(.*)(_[^_]{2,})(_.*)\2(.*):\1\2\3\4" etc
bru
 
Posts: 62
Joined: Wed Jan 31, 2018 7:35 pm


Return to Javascript Renaming