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:
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
Here’s what the rule looks like with the script pasted in:
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).”
As a sample, here are some files I had in a folder before implemeting the 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:
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.