#1 2011-02-08 09:22

RoSi
Member
Registered: 2011-02-08
Posts: 1

Change to UPPERCASE before " - " ?

Hello,

can somebody help me with Pascal Script that will rename everything in filename before " - " to UPPERCASE?

Thanks.

Offline

#2 2011-02-08 16:37

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

Re: Change to UPPERCASE before " - " ?

I have not searched the forum -there should be already threads about this issue-, but just paste you an script:

//From "Band Name - Song Title.mp3" to "BAND NAME - Song Title.mp3"
var
  Artist, Title, EXT: WideString;

begin

  //////             Split file name at the first dash into to parts:

  //////Artist is "Band Name"
  Artist := ReplaceRegEx(WideExtractBaseName(FileName), '(.+) - (.+)', '$1', False, True);
  
  //////Title is "Song Title"
  Title  := ReplaceRegEx(WideExtractBaseName(FileName), '(.+) - (.+)', '$2', False, True);

  //////Extension is "mp3"
  EXT :=  WideExtractFileExt(FileName)


  ////////////////////////


  //////             do the case conversions:
  //Artist := WideCaseCapitalize(Artist);
  Artist := WideUpperCase(Artist);
  //Title := WideCaseCapitalize(Title);
  //EXT := WideLowerCase( EXT);


  //////           build the new filename:
  FileName := Artist + ' - '  + Title + EXT;

end.

Here is an other approach with using ID3 tags >>> http://www.den4b.com/forum/viewtopic.php?id=312
And then i found ( ;-) ) this too >>> http://www.den4b.com/forum/viewtopic.php?pid=4873#p4873


HTH? big_smile

Last edited by Stefan (2011-02-08 16:43)


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

#3 2011-02-09 11:04

SDdave
Member
Registered: 2010-12-29
Posts: 6

Re: Change to UPPERCASE before " - " ?

Try this:

{ This script converts all characters left of first " - " to upper case }

Var
   ParsedFilename: TStringsArray;

Begin
   ParsedFilename := WideSplitString(WideExtractBaseName(FileName), ' - ');
   FileName :=  WideReplaceStr (FileName, ParsedFilename[0], WideUpperCase(ParsedFilename[0]));    
End.

Last edited by SDdave (2011-02-09 13:29)

Offline

#4 2011-02-09 13:39

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,380

Re: Change to UPPERCASE before " - " ?

This script would be a better alternative and more efficient:

var
  I: Integer;
begin
  I := WidePos('-', FileName);
  if I > 0 then
    FileName := WideUpperCase(WideCopy(FileName, 1, I - 1)) +
      WideCopy(FileName, I, WideLength(FileName) - I + 1);
end.

P.S. SDdave's script will work in most cases, but will also convert to upper case all occurrences of the "pre dash" part in the entire filename, if it occurs more than once.

Offline

#5 2011-02-09 18:01

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,380

Re: Change to UPPERCASE before " - " ?

I also put up two scripts on to Wiki to demonstrate the partial case change:
ReNamer:Scripts:Partial_case_change

Offline

Board footer

Powered by FluxBB