#!/usr/bin/env perl use strict; $|++; use Cwd qw(abs_path); use File::Temp qw(tempdir); @ARGV = map abs_path($_), @ARGV or die "$0: please give keynote zip names on command line"; while (@ARGV) { my $key = shift; -e $key or die "$key not found"; my $tempdir = tempdir( CLEANUP => 1 ); chdir $tempdir or die "cannot cd $tempdir: $!"; system "unzip", $key; my $flag = 0; { local @ARGV = "index.apxl"; local $^I = "~"; while (<>) { s#(.*?)## and $flag = 1 and warn "removed $1"; print; } } (warn "no changes made, skipping\n"), next unless $flag; my $old_key = $key; $old_key =~ s/\.key$/ OLD.key/ or $old_key .= "-OLD"; (warn "unsafe to mv $key $old_key, skipping\n"), next if -e $old_key; rename $key, $old_key or die "cannot mv $key $old_key: $!"; system "zip", "-r", $key, '.'; }