<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
# Mike Benjamin, August 2016
# usage: pq_compress.pl &lt;dir&gt; 
# where &lt;dir&gt; contains a bunch of files to be compressed.

$help = "";

foreach $arg (@ARGV) {
    if((index($arg, "-help") ==0) or
       (index($arg, "--help")==0) or
       (index($arg, "-h")==0)){
        $help = "yes";
    }
}

if($help eq "yes") {
    print "================================================ \n";
    print "Usage: pq_compress.pl &lt;dir&gt;                      \n";
    print "================================================ \n";
    print "SYNOPSIS:                                        \n";
    print "  Compress all files ending in .ipp in the given \n";
    print "  directory name &lt;dir&gt;                           \n";
    exit;
}

$dirname=shift;
opendir(DIR,$dirname) or die "can't opendir $dirname: $!";
@sorted=sort readdir(DIR);
closedir(DIR);

# Count the number of files with the right suffix so we 
# can keep a running progress indicater later on.
$array_size = 0;
foreach $file (@sorted) {
  next if $file=~/^\.\.?$/; # skip . and ..
  if ($file=~/\.ipp$/i) {
      $array_size++;
  }
}


# Now do the compressing
print "\nBeginning to compress files ...\n";
$counter = 1;
foreach $file (@sorted) {
  next if $file=~/^\.\.?$/; # skip . and ..
  if ($file=~/\.ipp$/i) {
      print "handling $counter of $array_size: $file -- compressing...\n";
      `gzip $dirname/$file `;
      $counter++;
  }
}
</pre></body></html>