You are not logged in.
Hello,
I want to change the initial capital letters of each word in a batch of files, but without changing what is inside parentheses or brackets.
Example:
BEFORE- [Superman] the death of superman (deluxe edition)
AFTER- [Superman] The Death Of Superman (deluxe edition)
Best regards and thank you for your help.
Last edited by geniusnet132 (Today 04:57)
Offline
You can use Pascal script rule. Based on one provided example pattern, this script should work:
var
BaseName, Prefix, Middle, Suffix: WideString;
PosStart, PosEnd: Integer;
begin
BaseName := WideExtractBaseName(FileName);
// Extract content inside square brackets
PosStart := Pos('[', BaseName);
PosEnd := Pos(']', BaseName);
if (PosStart > 0) and (PosEnd > PosStart) then
begin
Prefix := Copy(BaseName, PosStart, PosEnd - PosStart + 1);
Middle := Copy(BaseName, PosEnd + 1, Length(BaseName));
end
else
begin
Prefix := '';
Middle := BaseName;
end;
// Extract content inside parentheses at the end
PosStart := Pos('(', Middle);
PosEnd := Pos(')', Middle);
if (PosStart > 0) and (PosEnd > PosStart) then
begin
Suffix := Copy(Middle, PosStart, PosEnd - PosStart + 1);
Middle := Copy(Middle, 1, PosStart - 1);
end
else
begin
Suffix := '';
end;
// Capitalize the middle part
Middle := WideCaseCapitalize(Trim(Middle));
// Reconstruct the filename
FileName := Trim(Prefix + ' ' + Middle + ' ' + Suffix) + WideExtractFileExt(FileName);
end.
What this script does:
- extracts the part inside brackets [] () and keeps it unchanged
- capitalizes everything else using WideCaseCapitalize function
- reassembles the filename with proper spacing
Before:
[Superman] the death of superman (deluxe edition)
[SUPERMAN] the death of superman (DELUXE edition)
[superman] THE DEATH OF SUPERMAN (deluxe Edition)
After:
[Superman] The Death Of Superman (deluxe edition)
[SUPERMAN] The Death Of Superman (DELUXE edition)
[superman] The Death Of Superman (deluxe Edition)
P.S. You can modify script using AI, if required.
Offline