Difference between revisions of "ReNamer:Scripts:Separate words"

From den4b Wiki
Jump to navigation Jump to search
(Created page with 'Separate capitalized words with spaces. Useful for cleaning up some files downloaded from the internet. For example, if we have a file "''TheEverlyBrothers - AllIHaveToDoIsDream...')
 
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{Up|ReNamer:Scripts}}
 +
 
Separate capitalized words with spaces. Useful for cleaning up some files downloaded from the internet.
 
Separate capitalized words with spaces. Useful for cleaning up some files downloaded from the internet.
  
 
For example, if we have a file "''TheEverlyBrothers - AllIHaveToDoIsDream.mp3''" it will be converted into "''The Everly Brothers - All I Have To Do Is Dream.mp3''".
 
For example, if we have a file "''TheEverlyBrothers - AllIHaveToDoIsDream.mp3''" it will be converted into "''The Everly Brothers - All I Have To Do Is Dream.mp3''".
 +
 +
Note: Since beta version from 8.08.2009 this common task was integrated into the CleanUp rule.
  
 
== Tested ==
 
== Tested ==
Line 12: Line 16:
 
Author: Denis Kozlov. Date: 14 Sep 2008.
 
Author: Denis Kozlov. Date: 14 Sep 2008.
  
<source>
+
<syntaxhighlight lang="pascal">
 
var
 
var
 
   I: Integer;
 
   I: Integer;
Line 22: Line 26:
 
           WideInsert(' ', FileName, I);            // insert space
 
           WideInsert(' ', FileName, I);            // insert space
 
end.
 
end.
</source>
+
</syntaxhighlight>

Latest revision as of 15:00, 8 February 2017

Separate capitalized words with spaces. Useful for cleaning up some files downloaded from the internet.

For example, if we have a file "TheEverlyBrothers - AllIHaveToDoIsDream.mp3" it will be converted into "The Everly Brothers - All I Have To Do Is Dream.mp3".

Note: Since beta version from 8.08.2009 this common task was integrated into the CleanUp rule.

Tested

  • ReNamer 5.20
  • ReNamer 5.50

Code

Author: Denis Kozlov. Date: 14 Sep 2008.

var
  I: Integer;
begin
  for I := WideLength(FileName) downto 2 do        // for each character
    if IsWideCharAlpha(FileName[i]) then           // is alphabetic
      if IsWideCharUpper(FileName[i]) then         // is upper case
        if not IsWideCharSpace(FileName[i-1]) then // is space preceding
          WideInsert(' ', FileName, I);            // insert space
end.