1 (edited by Stefan 2007-05-26 20:49:38)

Topic: Upper case first letter but don't lower all the rest

Standard with 'U' modifier

EXAMPLE:         important PRIO1 document NEW.txt
EXPRESSION:   %Ub
RESULT:          Important Prio1 Document New.txt

This mofier change all chars to lower and then  makes the very first char of each word upper.

But i didn't want all the rest lower since i have important "remarks" in the file name which should keep as they are.
So i use an (long) RegEx to find the very first letter in each word and make them upper only, leaving the rest letters in the word as they are.


----------------------------------------------------------------------


Extended with RegEx
(Note: this is an first quickly try, YMMV, could be not guarantee correct results always)

EXAMPLE:         important PRIO1 document NEW.txt
EXPRESSION:   %b(s/\ba/A/g)(s/\bb/B/g)(s/\bc/C/g)(s/\bd/D/g)(s/\be/E/g)(s/\bf/F/g)(s/\bg/G/g)(s/\bh/H/g)
(s/\bi/I/g)(s/\bj/J/g)(s/\bk/K/g)(s/\bl/L/g)(s/\bm/M/g)(s/\bn/N/g)(s/\bo/O/g)(s/\bp/P/g)(s/\bq/Q/g)(s/\br/R/g)
(s/\bs/S/g)(s/\bt/T/g)(s/\bu/U/g)(s/\bv/V/g)(s/\bw/W/g)(s/\bx/X/g)(s/\by/Y/g)(s/\bz/Z/g)


(Note: you have to join the three EXPRESSION lines  into one very long line)

Result :   Important PRIO1 Document NEW.txt    (as expected)


----------------------------------------------------------------------


Extended with improved  RegEx
(Note: this is an first quickly try, YMMV, could be not guarantee correct results always)


To shorten the long EXPRESSION
i try to find an short RegEx like
%b( s/ \b ([a-z]) /  \U \1  /g)

EXPLANATION:
%b         Siren:     modifier to refer to the base of the file name
s/           RegEx:   search
\b           RegEx:  modifier to find the word boundary
( ...)       RegEx:   group that what you search for into an group you can back reference to later
[a-z]      RegEx:   the POSIX group of all lower case chars: a,b,c,d,e,f....x,y,z
/            RegEx:   set the 'replace with' apart from the 'search for'
\U          RegEx:   All (first char only, i think ) Chars Upper Case
\1          RegEx:   back reference to group number one
/g          RegEx:   search 'global'  instead of the first occurrence only



EXAMPLE:         important PRIO1 document NEW.txt
EXPRESSION:   %b(s/\b([a-z])/\U\1/g)
RESULT:           Important PRIO1 Document NEW.txt




--
Thanks to Boost for the fine Regular Expression Engine.  => http://scarabee.software.free.fr/forum/ … php?id=131
Thanks to rplr  for making such an great renamer.



------------------------------------------------------------------------------------------------------------

                                             Siren is a freeware file renaming program
                                               - portable, highly flexible, powerfully -
                                          If it's looking tricky it's easy to rename with Siren.
                                          http://www.scarabee-software.net/en/siren.html

Online