Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Clean Up AppleWorks temporary files' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Clean Up AppleWorks temporary files
Authored by: peterneillewis on Jan 28, '04 09:27:20PM
Yes, this has annoyed me too. But this hint inspired me to solve the problem. Save the following script, adjust the $maxrecent variable to somewhat less than your AppleWorks preference setting for number of recent files to remember, and then run the script from cron (crontab -e) using this line (adjusting the path to the script).

22 1 * * * perl '/Users/peter/perl/CleanAppleWorksRecent.pl'
then once per day the script will run and delete any old recent files and life will be much improved. Note that the script is quite pedantic about the listing romat to ensure it does not delete things it should not delete (so it ensures that the file size is zero for example).

#!/usr/bin/perl -w

use warnings;
use strict;
use diagnostics;

my $maxrecent = 25;
my $appleworks_recent_dir = "$ENV{HOME}/Documents/AppleWorks User Data/Starting Points/Recent Items";

my $count = 0;
chdir( $appleworks_recent_dir ) or die "Cant change to AppleWorks Recent Directory $!";
open( LIST, "/bin/ls -lt |" ) or die;
while ( <LIST> ) {
	chomp;
	next if m!^total \d+$!;
	die $_ unless s!^-rw-r--r--  1 \w+\s+\w+\s+0 [A-Z][a-z][a-z] [0-9 ]\d \d\d:\d\d ([^/]+)$!$1!;
	my $file = $1;
	$count++;
	if ( $count >= $maxrecent ) {
#		print "rm $file\n";
		unlink( $file );
	}
}
close( LIST );


[ Reply to This | # ]