Everyone's got a virtual junk drawer, that folder where you save downloads, email attachments, and disposable files you only need access to temporarily. Problem is, these files can build up over time, eat up disk space and clutter your go-to spot for noodling with documents. Recover hard drive space and keep your "junk drawer" from getting too cluttered with an automated task that sweeps through that temporary folder and deletes the old stuff you don't need.
Nearly two years ago, we introduced the hard drive janitor, a Windows script that deletes files older than a set number of days in a folder you define. Today, the Janitor script gets a much-needed upgrade.
Windows Janitor script
Version: 0.2.1
Updated: August 12, 2007
Released: October 26, 2005 (original post)
Author: Brian Plexico with minor modifications by Gina Trapani
What it does: Deletes all files that have a last modified date older than a number of user-specified days. The Janitor deletes all subfolders within a folder, and subtracts the number of days set by the user in the script (like 7 for a week or 30 for a month) from the current date. The Janitor can exclude user-specified subfolders.
Installation: Save the janitor_0.2.vbs
script to your PC's local drive.
Configuration: Open janitor_0.2.vbs
using a text editor like Notepad, and set the pathToClean
and numberOfDays
variables according to the instructions in the script.
To exclude particular subdirectories of the specified pathToClean
, either:
A. Add the folder names you want to skip to the foldersToSkip
line. Separate folder names with a semicolon. (Example: foldersToSkip = "Folder1;Folder2")
B. Create a file named "janitor.skip" in the folder(s) you want to leave alone.
Save the janitor_0.2.vbs
file.
IMPORTANT WARNING: This script deletes files from your hard drive, from any directory that you specify. Which means if you specify C:\Windows\, you can do irreparable damage to your computer for which neither I nor Brian will be held accountable. So! Ensure the PathToClean
is set to a directory with stuff in it Windows doesn't need to function, and stuff you don't care about losing.
Usage: Once Janitor.vbs has been saved and configured, run it by double-clicking on it. If you set pathToClean
to a root drive, or if the directory does not exist, you'll get an error message. Otherwise, you'll get a confirmation message like this:
To automatically run the script every day, use the Windows Task Scheduler.
Credits: Janitor.vbs was coded by the generous Brian Plexico and the janitor concept is by Danny O'Brien. Thanks, Danny and Brian!
Known Issues: Janitor.vbs deletes files x days older than the file's "Last Modified" date. It is possible that a file's Last Modified date is already older than the number of days you specify, even if you've just downloaded the file. Keep this in mind when you're saving files to your junk drawer. Only save stuff in your junk drawer which you're okay with losing.
How do you automatically sweep up your hard drive? Tell us about it in the comments.