Start each word in a folder name with uppercase

A swapping-ground for Regular Expression syntax

Start each word in a folder name with uppercase

Postby Neil Jones » Fri Jan 10, 2014 1:31 pm

Very new to this and can't get it to work. This is what I have entered under RegEx(1):

Match:

([\b][a-z])

Replace:

([A-Z])
Neil Jones
 
Posts: 13
Joined: Thu Jan 09, 2014 10:01 am

Re: Start each word in a folder name with uppercase

Postby Stefan » Fri Jan 10, 2014 4:51 pm

As I said, this syntax doesn't work with BRU:

Neil Jones wrote:Very new to this and can't get it to work. This is what I have entered under RegEx(1):

Match:

([\b][a-z])

Replace:

([A-Z])


1) the meta char for the beginning of a string is ^
\b means word boundary only (could be in the middle of string also)

2) you have to match (define) the whole file name, not only the wanted parts.
Means: ^([a-z])(.+)

3.) [a-z] and [A-Z] are only matching operators, they do not change the case.
Changing the case would do the \U and \L parameter some regex engines (or application) do provide.
Means:
Match: ^([a-z])(.+)
Replace: \U\1\2

But all that is not supported by BRU.








- - -

Luckily, den4b ReNamer had that implemented not long ago:
- add your folder as files (!!!)
- add rule RegEx
Match Expression: ^([a-z])
Replace: \U$1

(yes, here working on parts of file name is allowed/supported)




- - -


Or utilize PowerShell :


Open PowerShell and go to your folder, then type that:


Get-ChildItem | where {$_.PSisContainer -eq $true} | foreach { Rename-Item -path $_.FullName -NewName ( $_.Name -replace "^.", ( $_.Name.substring(0,1).toUpper() ) ) }



Or in short:


dir | ?{$_.PSisContainer -eq $true} | %{Ren $_.FullName ($_.Name -replace "^.", ($_.Name.substring(0,1).toUpper()))}



(to work recursively, utilize " dir -recurse | " )



--
EDIT:
changed to a much more simpler expression
Last edited by Stefan on Tue Jan 14, 2014 11:13 am, edited 2 times in total.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Start each word in a folder name with uppercase

Postby Neil Jones » Sat Jan 11, 2014 5:53 am

Stefan wrote:As I said, this syntax doesn't work with BRU:

1) the meta char for the beginning of a string is ^
\b means word boundary only (could be in the middle of string also)

2) you have to match (define) the whole file name, not only the wanted parts.
Means: ^([a-z])(.+)

3.) [a-z] and [A-Z] are only matching operators, they do not change the case.
Changing the case would do the \U and \L parameter some regex engines (or application) do provide.
Means:
Match: ^([a-z])(.+)
Replace: \U\1\2

But all that is not supported by BRU.


Luckily, den4b ReNamer had that implemented not long ago:
- add your folder as files (!!!)
- add rule RegEx
Match Expression: ^([a-z])
Replace: \U$1

(yes, here working on parts of file name is allowed/supported)



What you wrote above was extremely helpful to me, Stefan. I would never have figured out the proper structure without your help! Thank you for taking the time to respond is such a meaningful and detailed way. :D

I will download and start experimenting with ReNamer to see if I can get the hang of using Regular Expressions.
Neil Jones
 
Posts: 13
Joined: Thu Jan 09, 2014 10:01 am

Start FolderName words with Uppercase

Postby truth » Sat Jan 11, 2014 1:26 pm

12Folders=Checked (others-unchecked)
04Case=Title
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay

Re: Start FolderName words with Uppercase

Postby Stefan » Sat Jan 11, 2014 2:06 pm

truth wrote:12Folders=Checked (others-unchecked)
04Case=Title


That's not the same, because that would change the case for every sign, not the first one only:

before > after
addins > Addins
appCompat > Appcompat
AppPatch > Apppatch
de-DE > De-De
digitalLocker > Digitallocker



.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Start each word in a folder name with uppercase

Postby Neil Jones » Sat Jan 11, 2014 3:22 pm

12Folders=Checked (others-unchecked)
04Case=Title

This is what I'm using now and I have to do a lot of checking and editing. :cry:

"That's not the same, because that would change the case for every sign, not the first one only"

Right.
Neil Jones
 
Posts: 13
Joined: Thu Jan 09, 2014 10:01 am

Start folDerNamEs -> Foldernames

Postby truth » Sun Jan 12, 2014 4:39 am

12Folders=Checked
4Case=Title

Only word-chars following \b retain capitalization:

folderNaMe ---> Foldername (\b precedes f only)
folder-nAmE -> Folder-Name (\b precedes f, then n)
fOlder_name -> Folder-Name (\b precedes f, then n)
folder.naMe --> Folder.Name (\b precedes f, then n)

If you truly wish to also keep pre-existing Uppercases?
I'd use 26 CharTrans to change Uppercase -> ...Uppercase
with #4Case=Title and #5RemoveWords=...
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay

Re: Start each word in a folder name with uppercase

Postby Neil Jones » Sun Jan 12, 2014 5:13 am

I stumbled around till I found Character Translations under the Options Menu. I read the help file in regards to Character Translations. It says:

"Character Translations allows you to enter a specific character or sequence of characters, and have that translated into a different character or sequence of characters. So for example, you could specify that you always want a $ sign to be converted into the word DOLLAR."

I get that.

Then it says:

"Separate the FROM and the TO conversions with an equals sign."

I get that.

You wrote:

"I'd use 26 CharTrans to change Uppercase -> ...Uppercase with #4Case=Title and #5RemoveWords=..."

I don't know what the name of the words in the Folder name that will need to stay capitalized will be. They very greatly.
Neil Jones
 
Posts: 13
Joined: Thu Jan 09, 2014 10:01 am

Re: Start each word in a folder name with uppercase

Postby Neil Jones » Sun Jan 12, 2014 6:16 am

Another question about Character Translations. How do you get them to work? What I mean is what triggers them? I highlight the Folders I wish to change. I hit the Rename button and nothing happens.
Neil Jones
 
Posts: 13
Joined: Thu Jan 09, 2014 10:01 am

folDer naMe -> FolDer NaMe (uppercases stay intact)

Postby truth » Sun Jan 12, 2014 9:25 am

Sorry I dont always explain this well.. Basically, here are the settings:
12Folders=Checked
04Case=Title
05RemoveWords=...

Options/CharTrans example (to preserve all Uppercased-chars)
A=.,.,.,A
B=.,.,.,B
C=.,.,.,C
D=.,.,.,D
E=.,.,.,E
(and all the others, along with any specials you might have)
It preceeds all UppercaseChars with ... to ensure 04Case wont lowercase them.
Then 05RemoveWords removes the protective ...'s for the rename.

Once CharTrans is set, any matching selections in the right-pane should be affected.
The resultant newname should also be visible, without needing to click rename.

I've heard some people have a prob with CharTrans, having to close & restart the app.
Never had that prob, but its always a good idea to keep you CharTrans saved in a text-file anyway.
Last edited by truth on Sun Jan 12, 2014 12:46 pm, edited 1 time in total.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay

Re: Start each word in a folder name with uppercase

Postby Neil Jones » Sun Jan 12, 2014 10:38 am

Brilliant idea! :D Works perfectly. Thank you for your patience with this newbie!

Is this kind of "workaround" common when you use BRU? I think it's very clever.
Neil Jones
 
Posts: 13
Joined: Thu Jan 09, 2014 10:01 am

folDer naMe -> FolDer NaMe (uppercases stay intact)

Postby truth » Sun Jan 12, 2014 12:44 pm

Not common for what I do, but the forums seem to call for 'workarounds' more often.
I read something very similiar here loong ago, probably deleted now, couldnt find it.
Glad it helped!
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay


Return to Regular Expressions