#!/usr/bin/perl -w use strict; use File::Find; use File::stat; my $path = "T:\\"; find (\&wanted, $path); sub wanted { my $days = 10; my $stat = stat($_); # Access and Modified dates older then X days and not root if (-A $_ > $days && -M $_ > $days && !(/^\./) ){ # With a temp partition T:\ there are system files that can't be deleted if (!($_ =~ /^ntldr.*|nprotect.*|ntdetect.*|System.*|VIRTPART.*|.ini/i)) { printf "access date %s modify date %s File is %s\n", scalar localtime $stat->atime, scalar localtime $stat->mtime, $_; # unlink($_); } } }