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. =…') |
m (Text replacement - "<source>" to "<syntaxhighlight lang="pascal">") |
||
(4 intermediate revisions by the same user not shown) | |||
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. | ||
Line 5: | Line 7: | ||
== Tested == | == Tested == | ||
− | * ReNamer 5. | + | * ReNamer 5.74.4 Beta |
== Code == | == Code == | ||
Line 11: | Line 13: | ||
Author: SafetyCar. Date: 09 January 2009. | Author: SafetyCar. Date: 09 January 2009. | ||
− | < | + | <syntaxhighlight lang="pascal"> |
var | var | ||
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; | ||
Line 53: | Line 55: | ||
FileName := WideExtractBaseName(FileName) + ' ' + ArabicToRoman(Count) + WideExtractFileExt(FileName); | FileName := WideExtractBaseName(FileName) + ' ' + ArabicToRoman(Count) + WideExtractFileExt(FileName); | ||
end. | end. | ||
− | </ | + | </syntaxhighlight> |
Latest revision as of 15:03, 8 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.74.4 Beta
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.