Have Hazel Help With Your Document Destruction Policy

Have Hazel Help With Your Document Destruction Policy

Do you keep your electronic documents forever? Or do you delete them when they’re no longer needed?

Awesome DocumentSnap reader Bill from Minneapolis asked me this interesting question, and I couldn’t resist digging into it:

[How do you] clean out your paperless files when the information is no longer needed? I have been using TextExpander to add a line “Delete YYYYMMDD” which helps the entry but still requires searching and deleting files. Would Hazel be able to do that?

My first thought was “yes, of course Hazel can do that.” Then after looking into it a little bit, my second thought was “hmm, this isn’t as easy as I thought”.

Here’s what I eventually came up with (sorry Windows folks, this one is Mac only):

Create The Rule

Here’s my simple Hazel rule:

Hazel Rule

Here’s what it says in plain English:

“If there’s a file in our folder(s) that is a PDF and that matches the script I am asking you to run, set the color label to red”.

Of course, you could have Hazel move the files to an archived location or even delete them, but for the purposes of testing I just had it give a color label.

Create the Script

Click the Edit script icon, and paste in the following script:


mystring=“Delete $(date +%Y%m%d)”
case “$1” in
$mystring)
exit 0
;;
*)
exit 1
;;
esac

Here’s what the rule looks like with the script pasted in:

Hazel Rule With Script

Here’s what the script says in plain English:

“The thing we’re looking for is in the format ‘Delete YYYYMMDD’, where YYYYMMDD is today’s date. Look at the file that Hazel is checking out. If it has that in the name, exit with code 0 (which tells Hazel that it’s successful). If it doesn’t, exit with code 1 (not succesful).”

The Results

As a sample, here are some files I had in a folder before implemeting the rule:

Files Before Hazel Rule

I renamed one of them and added “Delete 20150526” to the end of the filename (today is May 26, 2015). You’ll see that Hazel recognized it and added the red color tag:

Files After Hazel Rule

A few things that I mentioned to Bill:

  • Make sure everything is backed up before implementing something like this.
  • Test the heck out of it on your own documents before letting it delete files.
  • Possibly instead of having Hazel delete them, have it move it to an external drive or give it a color tag and use a Saved Search to actually do the deletion manually.
  • Did I mention having a backup?

Do you have an easier way to have Hazel do what we’re trying to do? Do you bother deleting old files? Do you have a document destruction policy? Let us know what you do in the comments.

PS: If you’re interested in learning how to use Hazel to go paperless, I did a popular webinar on exactly that topic.

About the Author

Brooks Duncan helps individuals and small businesses go paperless. He's been an accountant, a software developer, a manager in a very large corporation, and has run DocumentSnap since 2008. You can find Brooks on Twitter at @documentsnap or @brooksduncan. Thanks for stopping by.

Leave a Reply 4 comments

gareth - July 8, 2015 Reply

Interesting. I’m a photographer, and I have a massive digital archive – lots of which is useless and really needs to be deleted to free up some useful disk space (or I buy more hard drives, which I really don’t want to do). However, the idea of tagging th images and then using Hazel to do the deletion, or perhaps a migration to an offline drive ready for deletion is a great idea.

Jörg - May 27, 2015 Reply

Deleting documents, why? In a private environment it makes no sense for me. With an automatism the threat is to big that I loose a document which I will need later again. But maybe it depends on the usecase?

    Brooks Duncan - May 27, 2015 Reply

    Yeah, I personally do not delete documents but some people prefer to reduce digital clutter. No right or wrong way with this stuff.

    (Now with businesses, in many cases there are compelling reasons for an implemented and defensible document destruction policy, especially in the US).

    Thierry - May 27, 2015 Reply

    I also keep all my documents and data.
    Usually my pdf and old reports from 10 years ago, are not the heaviest files I have on the drive.
    (The heavy ones are all the family pictures and movies, which I never delete)

Leave a Reply: