#!/usr/bin/perl # ################################################################### # # Name: diffem.pl # Author: pete@rasterweb.net # Date Created: 04.10.2002 # Date Modified: 04.10.2002 # # Purpose: I had two directories of files I had to merge. # I got sick of opening them all in BBEdit and doing a diff between # them, and the command line diff ain't that pretty. So this uses # the command line diff to do the first comparison, and if they're # the same, you're done. If not, it pops them open in BBEdit... # # This'll work on Mac OS X. You can change the editor from BBEdit # to whatever else will work for you... # # This is free software, you may use it and distribute it under the # same terms as Perl itself. # #################################################################### $file = shift; if ($file eq "") { print "Filename: "; $file = ; chomp ($file); } #################################################################### # edit these as needed $diffcmd = '/usr/bin/diff -b -B -i'; $editcmd = "open -a '/Applications/BBEdit 6.1/BBEdit 6.1 for OS X'"; $touchcmd = '/usr/bin/touch'; $dira = '/Users/foo/oldfiles/'; $dirb = '/Users/foo/newfiles/'; $filea = $dira .= $file; $fileb = $dirb .= $file; $debug = 0; # set to 1 for more info #################################################################### # if (!(-e ($filea))) { print "$filea does not exist\n"; } if (!(-e ($fileb))) { print "$fileb does not exist\n"; } if ( (!(-e ($filea))) or (!(-e ($fileb))) ) { exit; } $cmd = "$diffcmd $filea $fileb;"; print "\n $cmd\n\n" if ($debug > 0); print "\n\n"; $result = system ($cmd); if ($result == 0) { print "\n $file OK\n\n"; system ("$touchcmd $filea;"); } if ($result == 256) { print "\n $file needs checking\n\n"; system("$editcmd $filea;"); system("$editcmd $fileb;"); } __END__