Difference between revisions of "ReNamer:Scripts:Roman numerals serialization"
Jump to navigation
Jump to search
(Navigation) |
(Replaced the use of TStringsArray with TWideStringArray.) |
||
Line 17: | Line 17: | ||
Count: Integer; | Count: Integer; | ||
− | function ArabicToRoman(Number:Integer):WideString; | + | function ArabicToRoman(Number:Integer): WideString; |
var | var | ||
− | Fulls, Halves: | + | Fulls, Halves: TWideStringArray; |
AllFulls, AllHalves, Arabic, Roman: WideString; | AllFulls, AllHalves, Arabic, Roman: WideString; | ||
I, U: Integer; | I, U: Integer; |
Revision as of 11:32, 5 February 2017
The script does a serialization with roman numerals. The roman number is added at the end of the file name.
For example, "Book.doc" will turn into new "Book I.doc" and so on.
Tested
- ReNamer 5.50
Code
Author: SafetyCar. Date: 09 January 2009.
var
Count: Integer;
function ArabicToRoman(Number:Integer): WideString;
var
Fulls, Halves: TWideStringArray;
AllFulls, AllHalves, Arabic, Roman: WideString;
I, U: Integer;
begin
Roman := '';
Arabic := IntToStr(Number);
AllFulls := 'I|X|C|M|(X)|(C)|(M)';
AllHalves := 'V|L|D|(V)|(L)|(D)';
Fulls := WideSplitString(AllFulls, '|');
Halves := WideSplitString(AllHalves, '|');
for I:=0 to Length(Arabic)-1 do
begin
U := StrToInt(Arabic[Length(Arabic)-I]);
If U = 0 then Roman := Roman;
If U = 1 then Roman := Fulls[i] + Roman;
If U = 2 then Roman := Fulls[i] + Fulls[i] + Roman;
If U = 3 then Roman := Fulls[i] + Fulls[i] + Fulls[i] + Roman;
If U = 4 then Roman := Fulls[i] + Halves[i] + Roman;
If U = 5 then Roman := Halves[i] + Roman;
If U = 6 then Roman := Halves[i] + Fulls[i] + Roman;
If U = 7 then Roman := Halves[i] + Fulls[i] + Fulls[i] + Roman;
If U = 8 then Roman := Halves[i] + Fulls[i] + Fulls[i] + Fulls[i] + Roman;
If U = 9 then Roman := Fulls[i] + Fulls[I+1] + Roman;
end;
Result := Roman;
end;
begin
Count := Count + 1;
FileName := WideExtractBaseName(FileName) + ' ' + ArabicToRoman(Count) + WideExtractFileExt(FileName);
end.