You are not logged in.
Pages: 1
Hello,
can somebody help me with Pascal Script that will rename everything in filename before " - " to UPPERCASE?
Thanks.
Offline
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?
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
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
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
I also put up two scripts on to Wiki to demonstrate the partial case change:
ReNamer:Scripts:Partial_case_change
Offline
Pages: 1