bookcrop

Miscellaneous tools for digitizing books
git clone git://lumidify.org/bookcrop.git (fast, but not encrypted)
git clone https://lumidify.org/bookcrop.git (encrypted, but very slow)
git clone git://4kcetb7mo7hj6grozzybxtotsub5bempzo4lirzc3437amof2c2impyd.onion/bookcrop.git (over tor)
Log | Files | Refs | README

sort2.pl (468B)


      1 #!/usr/bin/env perl
      2 
      3 use strict;
      4 use warnings;
      5 use File::Copy qw(copy);
      6 
      7 my $destdir = shift;
      8 my $ext = shift;
      9 my $i = shift;
     10 
     11 if (scalar(@ARGV) % 2) {
     12 	die "Uneven number of images.\n";
     13 }
     14 my $digits = length(scalar(@ARGV));
     15 my $half = scalar(@ARGV) / 2;
     16 foreach my $j (0..$half-1) {
     17 	my $dest = sprintf("%0${digits}d.$ext", $i);
     18 	copy($ARGV[$j], "$destdir/$dest");
     19 	$i++;
     20 	$dest = sprintf("%0${digits}d.$ext", $i);
     21 	copy($ARGV[$#ARGV-$j], "$destdir/$dest");
     22 	$i++;
     23 }