diff options
Diffstat (limited to 'rename')
-rwxr-xr-x | rename | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -0,0 +1,31 @@ +#!/usr/bin/perl + +# rename -- automatically rename ditroff file + +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; +} |