aboutsummaryrefslogtreecommitdiff
path: root/rename
blob: cece8c967460914021ee6e5cffd1e8968fc76488 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl

# rename -- figure out troff font name

sub usage {
	die "usage: $0 [-n] family file\n";
}

usage if @ARGV != 2 and @ARGV != 3;
if ($ARGV[0] eq '-n') {
	$test = 1;
	usage if @ARGV != 3;
}
$family = $ARGV[-2];
$file = $ARGV[-1];

die "family '$family' should begin with capital letter\n"
	unless $family =~ /^[A-Z]+$/ or $family =~ m{/[A-Z]+$};

for ($file) {
	$family .= 'B' if (/Bold/);
	$family .= 'I' if (/Italic/);
	$family .= 'I' if (/Oblique/);
	$family .= 'R' if $family eq $ARGV[-1];
}

if ($test) {
	print "$file -> $family\n";
} else {
	rename $file, $family;
}