Script to automatically add spaces after certain words

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

Script to automatically add spaces after certain words

Postby Lathda » Sun Jun 19, 2022 3:10 pm

Hey, I am new to Bulk Rename Utility and I was wondering if someone could help me.

I would like to ask if anybody would be able to help me with an idea for a Javascript.

I have lots of file names such as "hippogriffblack" "drowridinglizard" "phasespider" "phasespidermother" "vermingiantwaspwalking" and "verminmonstrousscorpion"

And, since they are all in lower case, I wonder if it would be possible to do some scripting to signify words that spaces should be added to, so the results look like this,

"hippogriff black" "drow riding lizard" "phase spider" "phase spider mother" "vermin giant wasp walking" and "vermin monstrous scorpion"

I know I could go through and replace them all separately in BRU, but I feel as though a script could save me hours/days of work if I could just instead add a list of words that I want to add spaces to. Is this kind of thing possible?

I appreciate any reply and hope you have a fantastic day :)
Lathda
 
Posts: 1
Joined: Sun Jun 19, 2022 2:58 pm

Re: Script to automatically add spaces after certain words

Postby Admin » Wed Jun 22, 2022 11:41 am

Hi, do you have a list of possible words?
Admin
Site Admin
 
Posts: 2148
Joined: Tue Mar 08, 2005 8:39 pm

Re: Script to automatically add spaces after certain words

Postby therube » Wed Jun 22, 2022 3:45 pm

(Not JavaScript, but...)

You can find your wanted words with something like:

1:RegEx, enable v2
Code: Select all
Match:  (hippo)(?X)(phase)(?X)(spider)


Though I"m not sure what the Replace: code might be (or even if it would work).
What you'd want it be would be something like:
Code: Select all
Replace:  \1   (?X)\2   (?X)\3   

(And of course, you do need a list of words that you want "spaced".)
therube
 
Posts: 1100
Joined: Mon Jan 18, 2016 6:23 pm

Re: Script to automatically add spaces after certain words

Postby Luuk » Mon Jun 27, 2022 10:03 am

Im was going to say much like therube, except only putting \x20$1 inside for the "Replace", and then for the "Match" something like...
(drow|hippogriff|lizard|mother|scorpion|spider|vermin|wasp|giant|monstrous|phase|riding|walking)

Its still a lot of typing, but at least the "Replace" can be easier. Im often using the Notepad++ to invent the word-lists like this.
And when you paste the text inside of the bru, then clicking "File, Save As" can save much typing the next time!
Luuk
 
Posts: 484
Joined: Fri Feb 21, 2020 10:58 pm


Return to Javascript Renaming


cron