This plugin allows you to reclaim disk space and clean up your uploads folder by deleting old uploads you are no longer linking to.
It will identify unused files within your uploads folder, and give you the option of archiving then deleting some or all of these files.
Before any action is taken, Upload Janitor will automatically make a ‘tar’ archive of all files to be erased, including their original paths, so you can restore if necessary.
Download
Download Upload Janitor from the WordPress plugins directory.
If you like Upload Janitor, please consider buying one of my products.
Installation
- Unzip the package, and upload
upload-janitorto thewp-content/pluginsdirectory - Activate the plugin through the ‘Plugins’ menu in WordPress
- Visit ‘Upload Janitor’ within the ‘Tools’ menu in WordPress to use
How does it work?
This plugin inspects every file within the uploads folder. For each file, it searches pages or posts that
reference the file. That is, the plugin searches for the part of each file’s path that comes after the path
to the uploads folder, such as 2010/01/my great but forgotten image.jpg.
The path is searched as-is, as well as URL-encoded with ‘%20′ for spaces, and the same with ‘+’ for spaces -
2010/01/my%20great%20but%20forgotten%20image.jpg and 2010/01/my+great+but+forgotten+image.jpg. HTML entity-encoded
forms of all of these are also searched.
If no matches are found, then the file is considered unused.
Note that this plugin plays it safe, and does not distinguish between older post/page revisions and the current version of a post/page. If a revision references a file, the file will be considered still in use.
Restoring
If something goes wrong, you can always restore. If you have shell access to your site, this is easy. Simply log in,
navigate to your wp-content/plugins directory, and locate the Upload Janitor archive – it will look like
upload_janitor_archive_YYYY-mm-dd.tar.gz. Then, type:
tar zxf <archive name> .
This will restore all files within the archive.
If you do not have shell access to your server, you will have to download the archive, extract it, then upload the
contents back to your server. The archive will be accessible at http://your-blog.com/wp-content/uploads/upload_janitor_archive_YYYY-mm-dd.tar.gz
Changes
0.2
- Tweak for compatibility with some apparently buggy PHP installations
- Additional error reporting for ‘tar’ archiver
0.1
- Initial release
Related posts
- Hidden Tags Wordpress Plugin Hide certain tags/categories from the public...
- Private Tags Wordpress Plugin The “Private Tags” Wordpress plugin allows users to specify a...
- Some useful mini-plugins for Wordpress Three simple Wordpress plugins that provide shortcode-based functionality: Simple Google...
- ‘Paged Comments’ plugin theme for Elegant Grunge I’ve recently enabled the Paged Comments plugin for this site,...
- Custom Permalinks Custom Permalinks is a Wordpress plugin that gives you ultimate...
8 Comments
I’ve just installed this plugin which looks just what I wanted. I started it from ‘tools’ and it says that it is searching through the uploads folder which takes about a minute. The page then refreshes, and I get a 404. The URL is the same http://www.ifagiolini.com/wp-admin/tools.php?page=upload-janitor/upload-janitor.php but the 404 logger I’m running (part of the plugin ‘redirections’ by John Godley) shows the referrer as the main site.
Any ideas? It would be so great if I could get this to work as it looks like exactly what I need!
Best wishes Kieran
Hi Kieran,
It sounds to me like there may be a plugin interfering – If you feel up to it, you could try disabling some plugins, and seeing if Upload Janitor starts working for you.
The other possibility is that perhaps there’s actually a 501 server error happening – if you have a particularly large uploads folder, there’s a chance that the plugin is running out of memory. If you have the means to do so, try checking your error log and seeing if there’s anything telling in there. Or, if you can, try increasing your memory limit, if disabling plugins doesn’t provide any leads.
Hi,
Very great plugin but when I try to delete some files I’ve got an error when the plugin make the archive file : Encountered a problem while creating archive: The ‘tar’ utility reported error number 1.
Best wishes Stéphane
Hello Stéphane,
There’s some issue or other with your archive utility (tar) – It’s hard to know exactly what it is, but the easiest way forward is probably to back your uploads folder yourself, if you have the means to do so. You can proceed without making a backup, but I wouldn’t recommend it =)
I might add some extra reporting in the next version so tar problems are more clear.
Tried out this plugin, but had problems creating the tar. Seems proc_open is disabled on my server. Manually backed up the uploads folder and ran the plugin. Finished ok.
It deleted all my galleries and now I can get them restored. The images are still in the uploads directory (I even restored my backup), but now Wordpress won’t pick them up! Do you know how to fix this?
Hi Adam,
Ah yes, if your server is in safe mode, it may have trouble.
If you have a database backup, the simplest thing I can advise is to selectively restore the database entries that correspond to the images (or the whole database).
Failing that, it should be possible to put together a script to scan the entries in the uploads folder and re-enter the records in the database. It’d take a bit of doing, though. If you’re desperate, I’m happy to give you a quote (if so, give me a bell).
Sorry, should have said “can’t get them restored”.
Hi, I like your plugin, but had to undo the delete Im affraid. I use extra fields in my posts to show thumbnails on my homepage. Upload Janitor marked them all as unused causing me to delete them all. Luckily I had a backup. The plugin does however have a good function. Ill wait for the next version.