Can I do this? (new user)

Post any Bulk Rename Utility support requirements here. Open to all registered users.

Can I do this? (new user)

Postby JD » Mon Dec 05, 2005 6:51 pm

First of all, this has got to be the best bit of software I have come across for years! I have used it to sort out my lad's music collection and saved DAYS of work.
One problem I have, and I have trawled through the forum to see if there is a solution, is that my lad has ripped his entire CD collection incorrectly, all the track names have ended up with no spaces in them, for instance
CoffeeAndTea instead of Coffee And Tea
Is there any way BRU can sort this? Luckily, the first character of each word is capitalised.

Keep up the good work!
JD
 
Posts: 1
Joined: Mon Dec 05, 2005 6:37 pm

Postby Admin » Tue Dec 06, 2005 4:12 am

Hi JD,

Yes you can, but it would have to be done via a Regular Expression. I was asked the same question last week.

Unfortunately I don't have time to write down the RegExp required (I'm running a trainng course in India this week!) but I thin it should be achievable with a RegExp. Hopefully somebody else here can help whilst I'm away?

I will look at making this a specific feature in the future.


Jim
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Postby Stefan » Fri Dec 09, 2005 12:38 pm

Hi JD, hi Jim,

iam try to help.

1.) search for one upper case char ==> [A-Z]
2.) "group" this ===> (...) ==> ([A-Z])
3.) replace with what we have found in this group ===> \1

4.) search for one or more lower case char ==> [a-z]+
5.) "group" this search ===> (...) ==> ([a-z]+)
6.) replace with what we have found in this group ===> \2
7.) add an space after this two finds ==> \1\2 (do you see the blank? :D )

So you serach for your first word with ==> ([A-Z])([a-z]+)
and replace with ===> \1\2#    (Note: the #-char stands for an blank, don't wrote an # but make an space here)


Now make as many groups and replace as you want, depents on how many words you have.

Two words:
([A-Z])([a-z]+)([A-Z])([a-z]+)
\1\2 \3\4


Three words:
([A-Z])([a-z]+)([A-Z])([a-z]+)([A-Z])([a-z]+)
\1\2 \3\4 \5\6


Four words:
([A-Z])([a-z]+)([A-Z])([a-z]+)([A-Z])([a-z]+)([A-Z])([a-z]+)
\1\2 \3\4 \5\6 \7\8

Image

Press F1 in BRU for more "Regular Expressions" help.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Postby MechaMatt » Mon Nov 05, 2007 12:43 am

Hi guys, I've got a similar problem. I am renaming a load of files that vary in length such as;

ThisIsReallyAnnoying&.whatever
InThe4HrsISpentResearchingThisICouldHaveTypedThemOut.whatever

Surely their must be a standardised query that can put a space before every capital or after a row of lower-case letters or special characters rather than having to change the amount of groups every time?

My experiments so far have been along the lines of;

([a-zA-Z]) e.t.c but how to add a space? \s doesn't seem to work anywhere in this case. Arrrgh. And Google has failed me.
Any help for this teeth-grinding noobie would be fantastic.
MechaMatt
 
Posts: 2
Joined: Sun Nov 04, 2007 6:17 pm

Postby Stefan » Mon Nov 05, 2007 2:04 pm

Hy MechaMatt, welcome.

MechaMatt wrote:Surely their must be a standardised query
that can put a space before every capital or after a row of lower-case letters or special characters
rather than having to change the amount of groups every time?


For RegEx it's no problem to search for any occurrences of [A-Z] in the whole name and replace them with what ever.

But not the way how the RegEx engine is implemented into BRU.
Within BRU you have to build an expression to catch the whole file name, not only an part of it like an upper case letter.




My experiments so far have been along the lines of;

([a-zA-Z]) e.t.c

but how to add a space? \s doesn't seem to work anywhere in this case.


The 'space' you want in the replacement so just insert an real simple blank space in the replace field.
f.ex.
Search: ([A-Z])
Replace: ~\1
where the ~ should be an blank.


And if you use "quantifiers" as * or + then be shure to use them as *? and +? so they are non greedy.
Please se here for more help:
http://www.bulkrenameutility.co.uk/Foru ... ic.php?t=5
http://www.bulkrenameutility.co.uk/Foru ... c.php?t=27
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Postby Stefan » Mon Nov 05, 2007 2:21 pm

MechaMatt, i forgot an solution for you.

Just use 26 times

the Option #3 Repl.
Replace: H
With: ~H
[x] Match case
(where the ~ -sign mark an simple space blank)

in compination with the Option #5 Remove
[x] Trim (to trim the leading space in front of the name)

---

As an another solution i tried the character translation like
A= A
B= B
or
C=#C
D=#D (and then replace '#' with space)
but this doesn't work for me.... i have to test more.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Postby Stefan » Mon Nov 05, 2007 2:37 pm

No, it works!

1.)
in combination with the Option #5 Remove
[x] Trim (to trim the leading space in front of the name)

2.)
press Ctrl+F6 (menu Options > Character Translations...)

and write
A
=
blank
coma
A
Ctrl+ENTER
B
=
blank
coma
B
Ctrl+ENTER
...
etc
...

Or write it first into an text editor and then copy and paste it in the CharTrans field

or just use the code below:


to get:

Code: Select all
A= ,A
B= ,B
C= ,C
D= ,D
E= ,E
F= ,F
G= ,G
H= ,H
I= ,I
J= ,J
K= ,K
L= ,L
M= ,M
N= ,N
O= ,O
P= ,P
Q= ,Q
R= ,R
S= ,S
T= ,T
U= ,U
V= ,V
W= ,W
X= ,X
Y= ,Y
Z= ,Z


Store ths "code" in an text file in your BRU folder so you have it by hand if you need it.



Edit:


you can also include number like
4= ,4


---

If you don't want to split names like "BRU" then you need a much longer list like:
A,a= ,A,a
A,b= ,A,b
A,c= ,A,c
A,d= ,A,d
A,e= ,A,e
...
A,y= ,A,y
A,z= ,A,z
B,a= ,B,a
B,b= ,B,b
B,c= ,B,c
B,d= ,B,d
B,e= ,B,e
...


---
unfortunately BRU doesn't store this CharTrans list between sessions nor i can load/save it ?
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Postby Admin » Mon Nov 05, 2007 3:33 pm

BRU saves these details in your "Favourites" file. Press Ctrl+S and nominate a filename, then reload that next time.


Jim
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Postby MechaMatt » Tue Nov 06, 2007 7:57 pm

Wow thanks for the replies! And no flames either!

I tried the first suggestion ([A_Z]) then ~\1 ~=space and I got the whole filename wiped out apart from the first letter! So now I understand why the need for groups.

In the end I went for the 'Replace' x26 times option, which gave me a few weird filenames to fix afterwards as I had stuff in brackets but not too much grief.

Thanks again.
MechaMatt
 
Posts: 2
Joined: Sun Nov 04, 2007 6:17 pm

Postby Admin » Tue Nov 06, 2007 8:34 pm

No flames in this forum, all friendly people.

Glad you got it working, thanks for letting us know.


Jim
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Postby Glenn » Tue Nov 20, 2007 3:55 am

One alternative which might be simpler would be to use:
(?<=[a-z])(?=[A-Z])
to look for locations in the filename where lower/uppercase meet.

(?<=[a-z]) means find a location which has a lowercase letter behind it (positive lookbehind)
(?=[A-Z]) means find a location which has an uppercase letter ahead of it (positive lookahead)

In combination these find locations of lower/uppercase.
Note that these DO NOT capture anything - they merely find the position.
To capture the parts of the filename on both sides you would use
(.+?)(?<=[a-z])(?=[A-Z])(.*)
and replace with
\1 \2
Note: there is a space between \1 and \2.
Using (.+?) with the ? after the + makes it non greedy as Stephan has suggested above, and this will make sure it stops at the first matching position in the string.
MechaMatt could use a number or special character inside the lookaround to look for whatever, and some modification would make it work with the samples shown here.
The one sticky point with BRU is that it doesn't allow global replacement which means you have to run it multiple times for multiple replacements.

So, for the example JD gave in the initial inquiry you start out with

CoffeeAndTea

Run the replacement one cycle in BRU and the new filename is renamed
Coffee AndTea

Note the space before And.
The next pass the filename now has a space after Coffee and the Regex will now match before Tea, so run it another cycle and you have

Coffee And Tea

Any further cycles on this name will no longer match and will not change anything.

So, you can select the files that need changing and run it a few times, and only ones with more of these lower/upper combinations left will be changed, and those with fewer matches will stop changing when all replacements have been made.

Although a few renaming cycles are required, you don't have to change the expression each time to match different numbers of lower/uppercase in different filenames.

Cordially,
Glenn

If the lookaround solution seems to complicated you could also try
Match:

(.*?[a-z])([A-Z].*)$

replace the same as before:

\1 \2
Glenn
 
Posts: 28
Joined: Fri Apr 14, 2006 4:53 pm
Location: Winnipeg, Canada


Return to BRU Support