...ended up to write a perl script:
Code:
#!/usr/bin/perl
use strict;
use warnings;
my $num_args = $#ARGV + 1;
if ($num_args != 1) {
print "Usage: convertColors.pl inputfile\n";
exit;
}
my $file = $ARGV[0];
open my $fd, $file or die "Could not open $file: $!";
my %replacement = (
11 => 0,
7 => 1,
6 => 2,
39 => 3,
5 => 4,
47 => 5,
8 => 6,
9 => 7,
10 => 8,
62 => 9,
36 => 10,
40 => 11,
25 => 12,
23 => 13,
3 => 14,
1 => 15,
-1 => 16,
38 => 17,
33 => 18,
2 => 19,
44 => 20,
46 => 21,
24 => 22,
109 => 23,
-2 => 24,
4 => 25,
71 => 26,
34 => 27,
69 => 28,
104 => 29,
157 => 30,
154 => 31,
14 => 33,
20 => 34,
108 => 35,
17 => 36,
50 => 37,
18 => 38,
13 => 40,
74 => 41,
16 => 42,
15 => 43,
107 => 45,
19 => 46,
12 => 47,
51 => 52,
121 => 54,
98 => 57,
57 => 60,
52 => 61,
64 => 62,
82 => 63,
122 => 64,
96 => 68,
88 => 70,
86 => 71,
85 => 72,
42 => 73,
37 => 74,
56 => 77,
90 => 78,
60 => 79,
67 => 80,
70 => 81,
65 => 82,
150 => 84,
91 => 86,
97 => 89,
28 => 92,
26 => 100,
43 => 110,
73 => 112,
100 => 114,
76 => 115,
101 => 117,
41 => 118,
35 => 120,
32 => 125,
84 => 134,
66 => 135,
78 => 137,
61 => 142,
77 => 148,
119 => 150,
99 => 151,
81 => 178,
95 => 179,
83 => 183,
110 => 191,
105 => 212,
27 => 216,
103 => 226,
87 => 232,
63 => 272,
221 => 285,
80 => 288,
118 => 294,
115 => 297,
162 => 302,
120 => 308,
72 => 313,
59 => 320,
153 => 321,
156 => 322,
152 => 323,
158 => 326,
159 => 329,
155 => 330,
21 => 334,
58 => 335,
163 => 339,
94 => 351,
220 => 353,
29 => 366,
54 => 373,
48 => 378,
55 => 379,
22 => 383,
106 => 450,
31 => 462,
68 => 484,
49 => 503,
160 => 509
);
my $hadError = 0;
while( my $line = <$fd>) {
if ( $line =~ m/^([12345])\s+([-0-9a-fx]+)\s+(.*)/ ) {
my $dest = $replacement{$2};
if ( !defined $dest ) {
print "### ATTENTION: color $2 is not mapped\n";
$dest = $2;
$hadError = $hadError + 1;
}
print "$1 $dest $3\n";
}
else {
print $line;
}
}
if ( $hadError > 0) {
print "\nconversion had $hadError errors\n";
}
close $fd;