[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Small Script...



This script is supposed to delete files in a directory dropped onto it
which are more than 31 days old. It's a little messy, but it deletes
younger files as well. Anyone know what's up?

#!/usr/bin/perl

die "Usage: newfiles_aging.pl <directory>\n" if !$ARGV[ 0 ];
opendir( DIR, $ARGV[ 0 ] );
@dir = readdir( DIR );
close( DIR );
foreach $file( @dir ){
	$fullpath = "$ARGV[0]\:$file";
	$age = -M $fullpath || die "Couldn't get age of $fullpath: $!\n";
	print "$fullpath: $age\n";
	unlink $fullpath if $age > 31 || print "Couldn't unlink $fullpath: $!\n";
	}

- Strider Corinth

-- 
"I consider everything a loss compared to the surpassing greatness of
knowing Christ Jesus my Lord, for whose sake I have lost all things. I
consider them rubbish, that I may gain Christ..."

Philippians 3:8

  |
--+--
  |
  |


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch