Difference between revisions of "ReNamer:Scripts:Roman numerals serialization"
Jump to navigation
Jump to search
(Created page with '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. =…') |
(Navigation) |
||
Line 1: | Line 1: | ||
+ | {{Up|ReNamer:Scripts}} | ||
+ | |||
The script does a serialization with roman numerals. The roman number is added at the end of the file name. | The script does a serialization with roman numerals. The roman number is added at the end of the file name. | ||
Revision as of 20:22, 23 May 2010
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: TStringsArray;
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.