#!/usr/bin/perl -w
use strict;
use Carp;

my $dir = shift @ARGV;
croak "First argument must be a directory!" unless -d $dir;
$dir = $dir.'/' unless ($dir =~ m|/$|);

my $filename;
foreach $filename (@ARGV) {
  my $newfilename = $filename;
  $newfilename =~ s|^.*/||;
  
  $newfilename = $dir.$newfilename;

  my $command = "./bw_convert $filename $newfilename";
  print $command;
  print `$command`;
  print "\n";
}
