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


Click here to return to the 'The opposite: A date-limited Trash can' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
The opposite: A date-limited Trash can
Authored by: SeanAhern on Nov 09, '06 08:44:55PM
I use the opposite. I run a perl script that deletes anything from the ~/.Trash that's more than 2 weeks old. Running this once a day (with launchctl) ensures that my trash can never has really old things in it, but still provides me with the ability to recover from accidental deletions. The script is actually an extremely old perl script that I have never found a reason to change:
#!/usr/bin/perl

require "finddepth.pl";

# Traverse desired filesystems

&finddepth('/Users/ahern/.Trash/.');

exit;

sub wanted {
    (
        (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
        ! -d _ &&
        (int(-M _) > 14)
    ) &&
    unlink($_);

    rmdir $name if (-d _);  # Fails silently if directory has stuff in it.
}


[ Reply to This | # ]