palpic2png.c: improve, make usable with ppic binary files
[rofl0r-openDOW.git] / utils / scaledown-batch.pl
blob88476a47f763b044f32ccf477c62c7fe94f87eeb
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
5 use File::Basename;
6 use Cwd 'abs_path';
7 my $path = dirname(abs_path($0));
9 sub name_wo_ext {
10 my $x = shift;
11 my $l = length($x);
12 $l-- while($l && substr($x, $l, 1) ne ".");
13 return substr($x, 0, $l) if($l);
14 return "";
17 sub file_ext {
18 my $x = shift;
19 my $l = length($x);
20 $l-- while($l && substr($x, $l, 1) ne ".");
21 return substr($x, $l) if($l);
22 return "";
25 my $scale = shift @ARGV;
26 my $suffix = shift @ARGV;
27 die ("syntax: $0 downscalefactor suffix list-of-files") unless $scale =~ /^\d+$/ && defined($suffix);
28 for(@ARGV) {
29 my $newfile = name_wo_ext($_) . $suffix . file_ext($_);
30 my $cmd = $path . "/scaledown.out $scale $_ $newfile";
31 print $cmd, "\n";
32 system($cmd);