#1 2010-08-14 13:58

hurshut
Member
Registered: 2010-06-25
Posts: 7

Title Case with delimeter option

I prefer my music files named as <Artist> - <Title>  and I use Title Case. Renamer currently has no option for Title Case. I would like a Title Case option with ability to use " - " as a delimeter, so that I would not have to change last word of <Artist> and first word of <Title> manually to Upper Case.

Example :

Al Stewart - On The Border   Capitalize every for Word version

Al Stewart - on the Border    Title Case version

Al Stewart - On the Border    Title Case with - as delimeter  version

It may not seem a lot of work to do it manually, but it is if you have a large archive.

Offline

#2 2010-08-14 17:06

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: Title Case with delimeter option

Check out this Wikipedia table: http://en.wikipedia.org/wiki/Letter_cas … ion_titles

Now, which rules should Title Case follow?

Offline

#3 2010-08-14 20:11

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Title Case with delimeter option

Nice link to read Andrew.

But "Title Case" means just "Sentences Case" and should make all chars lower case, but the very first upper only.
Also "The     vitamins     are     in     my     fresh     california     raisins" for your example.


ReNamer can do that with Case-Rule and option: "First letter capital".

FROM:
"Al Stewart - On The Border"
TO:
"Al Stewart - On the border"


But one have to split the file name into parts at the dash '-' to make only the last part "Sentence Case".
Here is an work around to do that:
http://www.den4b.com/forum/viewtopic.php?pid=1484#p1484



Or simple use an PascalScript Rule with, e.g.,  this code:

var
  Artist, Title, TitleChar1: WideString;

begin
  Artist := ReplaceRegEx(WideExtractBaseName(FileName), '(.+) - (.+)', '$1', False, True);
  Artist := WideCaseCapitalize(Artist);
  
  Title  := ReplaceRegEx(WideExtractBaseName(FileName), '(.+) - (.+)', '$2', False, True);
  
  TitleChar1 := WideCopy(Title, 1, 1);
  TitleChar1 := WideUpperCase(TitleChar1);
  
  Title := WideCopy(Title, 2, Length(Title) );
  Title := WideLowerCase(Title);

  FileName := Artist + ' - ' + TitleChar1 + Title
              + WideUpperCase( WideExtractFileExt(FileName) );
end.

HTH? big_smile

(Read our wiki how to use an script >> http://www.den4b.com/wiki/ReNamer:Rules:PascalScript )





And Denis, i want to suggest to implement "WideTitleCase()" as new PascalScript command big_smile  We need that every now and then.



--

If you really want to rename to "Al Stewart - On the Border"
then you can use this PascalScript

var
  Artist, Title, TitleChar1: WideString;

begin
  Artist := ReplaceRegEx(WideExtractBaseName(FileName), '(.+) - (.+)', '$1', False, True);
  Artist := WideCaseCapitalize(Artist);
  
  Title  := ReplaceRegEx(WideExtractBaseName(FileName), '(.+) - (.+)', '$2', False, True);
  Title := WideCaseCapitalize(Title);
  
  //Own dictionary rules:
  //List taken from MP3 ID3 Renamer MP3BookHelper and Media Tagger
  Title := WideReplaceText(Title, ' A ', ' a '); 
  Title := WideReplaceText(Title, ' Aka ', ' aka ');
  Title := WideReplaceText(Title, ' An ', ' an ');  
  Title := WideReplaceText(Title, ' And ', ' and '); 
  Title := WideReplaceText(Title, ' At ', ' at ');  
  Title := WideReplaceText(Title, ' But ', ' but '); 
  Title := WideReplaceText(Title, ' By ', ' by '); 
  Title := WideReplaceText(Title, ' For ', ' for '); 
  Title := WideReplaceText(Title, ' From ', ' from '); 
  Title := WideReplaceText(Title, ' If ', ' if '); 
  Title := WideReplaceText(Title, ' Is ', ' is ');  
  Title := WideReplaceText(Title, ' In ', ' in ');  
  Title := WideReplaceText(Title, ' Into ', ' into '); 
  Title := WideReplaceText(Title, ' It ', ' is '); 
  Title := WideReplaceText(Title, ' Go ', ' go ');    
  Title := WideReplaceText(Title, ' Feat ', ' feat ');  
  Title := WideReplaceText(Title, ' On ', ' on ');  
  Title := WideReplaceText(Title, ' Onto ', ' onto ');  
  Title := WideReplaceText(Title, ' Out ', ' out ');  
  Title := WideReplaceText(Title, ' Over ', ' over ');  
  Title := WideReplaceText(Title, ' Of ', ' of '); 
  Title := WideReplaceText(Title, ' Off ', ' off '); 
  Title := WideReplaceText(Title, ' Or ', ' or '); 
  Title := WideReplaceText(Title, ' Nor ', ' nor '); 
  Title := WideReplaceText(Title, ' The ', ' the ');
  Title := WideReplaceText(Title, ' To ', ' to ');  
  Title := WideReplaceText(Title, ' Up ', ' up ');  
  Title := WideReplaceText(Title, ' Vs ', ' vs '); 
  Title := WideReplaceText(Title, ' With ', ' with ');  
  Title := WideReplaceText(Title, ' Up ', ' up ');  
  Title := WideReplaceText(Title, ' Down ', ' down ');  
  Title := WideReplaceText(Title, ' Left ', ' left ');  
  Title := WideReplaceText(Title, ' Right ', ' right ');  
  Title := WideReplaceText(Title, ' Ii ', ' II '); 
  Title := WideReplaceText(Title, ' Iii ', ' III '); 
  Title := WideReplaceText(Title, ' Iv ', ' IV ');
  Title := WideReplaceText(Title, ' Vi ', ' VI ');
  Title := WideReplaceText(Title, ' Vii ', ' VII ');  
  Title := WideReplaceText(Title, ' Viii ', ' VIII ');
  Title := WideReplaceText(Title, ' Ix ', ' IX ');
  Title := WideReplaceText(Title, ' Xi ', ' XI ');
  //...yours here

  FileName := Artist + ' - '  + Title
              + WideLowerCase( WideExtractFileExt(FileName) );
end.

Or use an dedicated ID3 Renamer which has this feature build in.
.

Last edited by Stefan (2010-08-14 21:31)


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#4 2010-08-26 17:59

auwebio
Member
From: Brazil
Registered: 2010-07-07
Posts: 45

Re: Title Case with delimeter option

hurshut wrote:

I prefer my music files named as <Artist> - <Title>  and I use Title Case....ability to use " - " as a delimeter...last word of <Artist> and first word of <Title> manually to Upper Case.

Hey, hurshut,
I don't know exactly where you're coming from... Maybe it would be usefull to do a more detailed drescription as to what sort of mixed cases you get on the whole (how all the names usually comes for your lists).

I normally use a Tag-Renamer program specifically for music file renaming, but it is nowhere near as powerful as ReNamer is, so I always pass all the renamed files again on ReNamer to correct possible "mistakes", exactly like your example "Al Stewart - on the Border" ---to---> "Al Stewart - On the Border".

Although Stefan really solved your case, here's the PascalScript I personally use:

var SPLT: TStringsArray;
begin
    // Next Upper Case with " - " delimiter: e.g. "Stacey Kent - the Boy Next Door" to "Stacey Kent - The Boy Next Door"
    If length(MatchesRegEx(FileName, '(\w.+?\s-\s)([a-z])(.+)', False))>0 then begin
        SPLT := SubmatchesRegEx(FileName, '(\w.+?\s-\s)([a-z])(.+)', False);
        FileName := SPLT[0] + WideUpperCase(SPLT[1]) + SPLT[2];
    end;
    // Next Upper Case with " & " delimiter: e.g. "Marina & the Diamonds - Oh No" to "Marina & The Diamonds - Oh No"
    If length(MatchesRegEx(FileName, '(\w.+?\s\&\s)([a-z])(.+)', False))>0 then begin
        SPLT := SubmatchesRegEx(FileName, '(\w.+?\s\&\s)([a-z])(.+)', False);
        FileName := SPLT[0] + WideUpperCase(SPLT[1]) + SPLT[2];
    end;
    // Next Upper Case with " (" delimiter: e.g. "Timbaland - Shock Value II (the Essentials)" to "Timbaland - Shock Value II (The Essentials)"
    If length(MatchesRegEx(FileName, '(\w.+?\s\()([a-z])(.+)', False))>0 then begin
        SPLT := SubmatchesRegEx(FileName, '(\w.+?\s\()([a-z])(.+)', False);
        FileName := SPLT[0] + WideUpperCase(SPLT[1]) + SPLT[2];
    end;
end.

It really works great for my needs. Maybe it can help you too...  wink

Offline

#5 2010-08-26 18:31

auwebio
Member
From: Brazil
Registered: 2010-07-07
Posts: 45

Re: Title Case with delimeter option

By the way, on the same note of the title of this suggestion topic, I would like to suggest something like this:

Before ReNamer I used "Flexible Renamer" ( http://hp.vector.co.jp/authors/VA014830 … /FlexRena/ ), and there I had an option to alter the case of either regex or wild card expressions results, like this:

When searching for (.+\s-\s)(.+) we had an option to have the results go like this: "/1/u/2", which made the first letter of the second group upper case.

Or this search (.+?\s)(.+)\s(.+) could have the results going like this: "/1/U/2/E/3", which made all go upper case until the next /E (in this example, the second group).

On Summary, we had /u,/U,/l,/L,/E to change the case of individual group results of Regex matches.

I believe right now the Case Rules on ReNamer only work on the whole filename or nothing at all (I might be wrong by pure ignorance) and the only alternative to individual case handling (on single groups/parts of the filename) is to write a whole PascalScript to handle that.

I don't know how hard would it be to program something like this on ReNamer, but I am a firm believer it would be major beneficial to all users. Regular users, for whom the thought of doing a simple Pascal programming can appear impossible and terrifying, would greatly benefice from that.

Offline

#6 2010-08-30 17:00

hurshut
Member
Registered: 2010-06-25
Posts: 7

Re: Title Case with delimeter option

Hi, guys. Thanks for the responses.

auwebio wrote:

I don't know exactly where you're coming from...

I wonder if it was my broken English that lead you to ask where I come from.  (I even misspelled delimiter, even tough it still seems the right way to write it as "delimeter"). I am from Turkey.

Andrew wrote:

Check out this Wikipedia table: http://en.wikipedia.org/wiki/Letter_cas … ion_titles

Now, which rules should Title Case follow?

I am aware that there are different styles of Title Case, I just didn't want sound like I am giving a specific order.:)

For the record : "The     Vitamins are in my Fresh California Raisins" suits my liking.

Now for the guys asking for further description:

I used Rename Master before finding out about ReNamer, it does have a Title Case conversion option, now I only use it for that purpose, rest of the time I use ReNamer, especially : "Mark Only Changed" and after that "Clear Not Marked" makes my day. btw: there should be a way make this, the default view.

My problem is when don't have delimiter option with title case, it messes up other names:

Example:

"La Roux - In For The Kill" which should be "La Roux - In for the Kill" but without delimiter it is "La Roux - In for the Kill"

"Suede - The Drowners" which does not need modification but without delimiter it becomes "Suede - the Drowners"

Anyways, thanks again for scripts.

Offline

#7 2010-08-30 17:02

hurshut
Member
Registered: 2010-06-25
Posts: 7

Re: Title Case with delimeter option

Correction:
"La Roux - In For The Kill" which should be "La Roux - In for the Kill" but without delimiter it is "La Roux - in for the Kill"

Offline

#8 2010-08-30 22:34

auwebio
Member
From: Brazil
Registered: 2010-07-07
Posts: 45

Re: Title Case with delimeter option

hurshut wrote:

I wonder if it was my broken English that lead you to ask where I come from.  (I even misspelled delimiter, even tough it still seems the right way to write it as "delimeter"). I am from Turkey.

Hi, hurshut,
oh, man, I'm afraid I wasn't very clear - which probably means my English is much worse than yours lol (I'm from Brazil).
What I meant with "where you're coming from" was more in the lines of "what is the specific problem that you're trying to solve", or "what kind of sample strings do you have to modify", or "what have you already tried doing", and so forth...
I must really apologize to you. I meant in no way, shape or form to criticize your English skills. About the "delimeter", I would probably make the same mistake, but I use Opera Browser, and it has its own dictionary and it underlines and suggests the wright spelling for me (just like Microsoft Word). I highly recommend anyone to change to Opera, it's the most amazing browser in the world.

Anyways, thanks again for scripts.

Did any of those solved your problem?

Offline

#9 2010-08-31 09:17

hurshut
Member
Registered: 2010-06-25
Posts: 7

Re: Title Case with delimeter option

Hello Auwebio,

After trying your script, I understand why you were asking for clarification.

Here it is:

// "-" is the delimiter, $1 is the sentence before the delimiter and $2 is the sentence after the delimiter
$1 - $2

Here is what I want:
$1's first and last word's first letter should be capitalized

$2's first and last word's first letter should be capitalized

$1's rest of the words (other than first and last) first letter should be capitalized unless they are articles, prepositions, conjunctions, and forms of to be, if they are one of these, the first letter of the word should be lowercase

$2's rest of the words (other than first and last) first letter should be capitalized unless they are articles, prepositions, conjunctions, and forms of to be, if they are one of these, the first letter of the word should be lowercase

I hope this description if is enough:)

Your script does not solve my problem as you may imagine.

Stefan's script although works nicely has a few problems too:

$1 is affected opposite of what I want > "Boards of Canada" becomes "Boards Of Canada"

ain't becomes ain'T

Offline

#10 2010-08-31 20:13

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Title Case with delimeter option

hurshut wrote:

Here it is:

// "-" is the delimiter, $1 is the sentence before the delimiter and $2 is the sentence after the delimiter
$1 - $2

Here is what I want:
$1's and $2's  first and last word's first letter should be capitalized

$1's and $2's rest of the words (other than first and last) first letter should be capitalized
unless they are articles, prepositions, conjunctions, and forms of to be, if they are one of these, the first letter of the word should be lowercase

Understood.
But what word are "articles, prepositions, conjunctions, ..." you have to add to the script at your own.


hurshut wrote:

Stefan's script although works nicely has a few problems too:

$1 is affected opposite of what I want > "Boards of Canada" becomes "Boards Of Canada"

The tools i know all use Title Case the same as i did. Because non of this tools are aware of "articles, prepositions, conjunctions, ..." .
All just makes the first letter of all words upper case.

hurshut wrote:

ain't becomes ain'T

That could be if ' is an word separator. But i didn't see this behavior anyway while using any of my script above?!??


So for your issue you can try this new script, but you have to add some work at your own ("articles, prepositions, conjunctions, ..." Artist names,...)


FROM:
Boards of  ain't the Canada - new the happy song.mp3
Al Stewart - on the Border.mp3
Whitney Houston - I Will Always Love You
Olivia Newton-John - Summer Nights
B-52's - Love Shack
Kool & The Gang - Celebration
Diana Ross & Lionel Richie - Endless Love
Bob Seger - Old Time Rock & Roll
Bette Midler - The Rose
Joe Cocker & Jennifer Warnes - Up Where We Belong
Bette Midler - Wind Beneath My Wings
Elton John - Don't Let The Sun Go Down On Me

TO:
Boards of  ain't the Canada - New the happy Song
Al Stewart - On the Border
Whitney Houston - I will always love You
Olivia Newton-John - Summer Nights
B-52's - Love Shack
Kool & the Gang - Celebration
Diana ross & lionel Richie - Endless Love
Bob Seger - Old time rock & Roll
Bette Midler - The Rose
Joe cocker & jennifer Warnes - Up where we Belong
Bette Midler - Wind beneath my Wings
Elton John - Don't let the sun go down on Me


USE:
(Only for your issue, not many tested, not with all possible filenames tested, for sure needs improvements)

1.) Use an Rule to lower case the whole file name
2.) Use an Rule to replace some words from an text file for ("articles, prepositions, conjunctions, ...") (i remember there is
      an dictionary script somewhere that could maybe adapted?!?
      EDIT: Found: Andrew posted an nice howto for the script i had in mind there ==> http://www.den4b.com/forum/viewtopic.php?pid=2892#p2892
3.) Use this rule below:

var
  Artist, ArtistFirstWord, ArtistLastWord, ArtistMiddle: WideString;
  Title, TitleFirstWord, TitleLastWord, TitleMiddle: WideString;
  Parts: TStringsArray;
  I: Integer;
  
begin  
  //// Adjust the case for the whole FileName:
  //// (OR USE AN ANOTHER RULE FOR THIS TO BE MORE FLEXIBLE)
  //FileName := WideLowerCase(WideExtractBaseName(FileName));  

  //Own dictionary rules:
  FileName := WideReplaceText(FileName, ' renamer ', ' ReNamer '); 
  //...yours here
  FileName := WideReplaceText(FileName, ' dj ', ' DJ ');
  FileName := WideReplaceText(FileName, ' rmx ', ' RMX ');

  //// Split the file name at the - into Artist and Title part:
  Artist := ReplaceRegEx(WideExtractBaseName(FileName), '(.+) - (.+)', '$1', False, True);
  Title  := ReplaceRegEx(WideExtractBaseName(FileName), '(.+) - (.+)', '$2', False, True);


  //// Split the Artist part at an space into parts:
  Parts := WideSplitString( Artist , ' ' );
   If (Length(Parts) = 1) then
      ArtistFirstWord := Parts[0];
   If (Length(Parts) > 1) then
    begin
      ArtistFirstWord := Parts[0] + ' ';
      ArtistLastWord  := Parts[Length(Parts) -1];
    end;
   If (Length(Parts) > 2) then
    begin
      For I := 1 To Length(Parts) -2 do
      ArtistMiddle    := ArtistMiddle + Parts[i]  + ' ';
    end;
  
  Parts := WideSplitString( Title , ' ' );
   If (Length(Parts) = 1) then
         TitleFirstWord := Parts[0];
   If (Length(Parts) > 1) then
    begin
      TitleFirstWord := Parts[0] + ' ';
      TitleLastWord  := Parts[Length(Parts) -1];
    end;
   If (Length(Parts) > 2) then
    begin
      For I := 1 To Length(Parts) -2 do
      TitleMiddle    := TitleMiddle + Parts[i]  + ' ';
    end;

   //// Adjust the case for the First and the Last word:
   ArtistFirstWord := WideCaseCapitalize(ArtistFirstWord);
   ArtistLastWord  := WideCaseCapitalize(ArtistLastWord);
   TitleFirstWord  := WideCaseCapitalize(TitleFirstWord);
   TitleLastWord   := WideCaseCapitalize(TitleLastWord);


   //// Build the new FileName:
   FileName := ArtistFirstWord + ArtistMiddle + ArtistLastWord + ' - ' 
            + TitleFirstWord + TitleMiddle + TitleLastWord
            + WideLowerCase( WideExtractFileExt(FileName) );



   //// Clean up for the next file:
   Artist := '';
   ArtistFirstWord := '';
   ArtistLastWord := '';
   ArtistMiddle := '';
   Title := '';
   TitleFirstWord := '';
   TitleLastWord := '';
   TitleMiddle := '';
   //Parts := ;
   I := 0;
end.

HTH? smile

Last edited by Stefan (2010-08-31 20:21)


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

Board footer

Powered by FluxBB