How to Automatically Clean Up Your Desktop With Hazel


If you’re anything like me, your desktop gets cluttered with screenshots, random documents you wanted easy access to, and (above all) duplicate files! Thankfully, there’s a program out there that can help people like me handle this automatically, and it’s called Hazel . I’m going to walk you through my setup here, which you can customize to meet your needs, of course.
Remove Old Screenshots from the Desktop
First of all, let’s tackle screenshots. Personally, I prefer to leave my screenshots on my desktop for an hour, and then dump them into Dropbox if they’re still around. This means that regardless of which device I take the screenshot on, I will be able to find it if I need it later in the week. But if I have already moved it or deleted it, then it won’t be in the general screenshot folder.

Start by adding your Desktop to the list of folders Hazel monitors, and then add a rule. In this rule, we want to add three conditions:

Name contains Screenshot

Date Added is not in the last 1 hour
Kind is Image

This is going to find any images with “screenshot” in the name that were not put on the desktop in the last hour (so if we move an old screenshot to the desktop for some reason, it won’t instantly disappear). We just need one action that Hazel will complete if these conditions are true:

Move to folder Screenshots

In my case, I have a folder called Screenshots in Dropbox where I like all of my screenshots to go, and I selected this through the Other… option in the list.
Move Old Files Off the Desktop
Next up are the random files that litter my desktop. These can be split into three groups: PDFs, Images, and everything else, which includes anything from Pages documents to ZIP files. I move PDFs to my documents folder after 2 hours and import images into my Photos Library.
These rules are very similar to one another, so I’ll explain them together. The conditions are:

Kind is PDF or Kind is Image (hopefully you can guess which one applies to which!)
Date Added is not in the last 2 hours



Where they differ is in the actions they execute. PDFs are moved to the Documents folder, and Images are imported into Photos under a default album called Library .
Everything Else
This leaves us with the last category: everything else.

I configured my system to give me 24 hours to handle everything else on my desktop, but once that 24 hours is up, these files are moved to the trash. I’ve accomplished this with two conditions:

Any File
Date Added is not in the last 1 day

And then there’s one action which is run:

Move to Trash.

In the Hazel overview I’ve made sure my rules are ordered by the amount of time to wait, so the screenshots are first, images and PDFs second and third, and the Everything Else rule is last.

On top of this, I’ve ticked the box to throw away duplicate files, which handles the worst offender straight off the bat. If I search for the file on my desktop, I’ll still find it. On the odd occasion I need to duplicate a file, I can still do that and rename the copy before Hazel kicks in and deletes it.

Have fun making Hazel clean your desktop for you! You can download the rules here directly to modify and configure to your taste: Desktop.hazelrules .


window.rmpanda = window.rmpanda || {};
window.rmpanda.wpvars = window.rmpanda.wpvars || {};

var debug = (window.rmpanda || {}).debug || /rmdebug=1/.test(window.location.search);
var logger = {};
Object.keys(console).forEach(f => {
if (typeof console[f] === 'function') {
logger[f] = function() {
debug && console[f].apply(console, Array.prototype.slice.call(arguments));
};
}
});

function pipelistToArray(pipelist) {
return (pipelist || '').replace(/^|||$/g, '').split('|');
}

function arrayToPipelist(array) {
return '|' + (array || []).join('|') + '|';
}

function createLeaderboard(cachedPosts, dataKey) {
var leaderboard = {};
var totalRead = cachedPosts.length;

cachedPosts.forEach(function(pageview, idx) {
var pID = pageview[0]; var slugs = pageview[1][dataKey];
var score = 0.5 + ((1.0 - (idx / totalRead)) * 0.5);
slugs.forEach(function(slug) {
leaderboard[slug] = leaderboard[slug] || 0;
leaderboard[slug] += score;
});
});

return leaderboard;
}

function findLeaderboardWinners(leaderboard) {
var winningScore = 0;
var winners = [];
Object.keys(leaderboard).forEach(function(candidate) {
var candidateScore = leaderboard[candidate];
if (candidateScore >= winningScore) {
winningScore = candidateScore;
if (candidateScore > winningScore) {
winners = [];
}
winners.push(candidate);
}
});
return winners;
}

window.rmpanda.wpvars = {};

var cachedPosts = JSON.parse(localStorage.getItem('rmCachedPosts')) || [];


var categoriesLeaderboard = createLeaderboard(cachedPosts, 'categories');
logger.log("CATEGORIES LEADERBOARD:", categoriesLeaderboard);

var tagsLeaderboard = createLeaderboard(cachedPosts, 'tags');
logger.log("TAGS LEADERBOARD:", tagsLeaderboard);

window.rmpanda.wpvars.favoriteCategorySlugs = arrayToPipelist(findLeaderboardWinners(categoriesLeaderboard));
window.rmpanda.wpvars.favoriteTagSlugs = arrayToPipelist(findLeaderboardWinners(tagsLeaderboard));

localStorage.setItem('rmCachedPosts', JSON.stringify(cachedPosts));


Top News