The Short Version:
Download 4 fantastic scripts here, place them in the root of your website, then go to the appropriate addresses in your browser.
Save the reports to your hard drive using CTRL+S (CMD+S on a Mac).
Remember to delete the scripts from your website when done!
The Long Version:
The other day, I decided it was time to move my site to a different host. I fired up my backup script and was a bit surprised to see the archive was 4.5 GB.
Clearly, it was time to do some housecleaning.
I logged into CPanel and clicked “Disk Space Usage.” It took me to a lovely page that showed me the /public_html/ directory was 15,771.89 MB … but it wouldn't give me any size info about any directories INSIDE that directory.
I then poked around “cPanel File Manager v3,” which let me browse the file structure, but also wouldn't tell me which files or directories on my website were taking up the most space.
After a bit of Googling, I found this lovely script that listed, on a single page, every single file and directory on my website.
I then found a nice guy on Upwork to help me make some edits and provide a few different versions of the script.
#1: Viewing File Size
The first one, a minor modification of the original, shows the size beside each file.
Sample screenshot of result:
Download the script here, place it in the root of your website, and go to the appropriate address in your browser.
While it certainly gives you a well-organized list of files and directories, it isn't very useful if you want to quickly find out where the biggest files on your website are.
#2: Sorting by File Size
For the second script, I thought it would be useful to take the same information, but display it in order of file size (from largest to smallest).
Sample screenshot of result:
This will show you right away if you have any large backup files, video files or images that can be deleted to free up space.
You can download the script here.
#3: Sorting by Directory Size
And, for your final act, use this handy-dandy script to find out which directories on your site are taking up the most space!
Sample screenshot of result:
Download the script here.
#4: Sorting by Date (NEW!)
Suspect your site has been hacked? Use this script to list all files on your website and sort them by date (newest to oldest).
Any recently-modified files (which may have received malicious code injections) will be listed near the top.
This will even show the “proper” dates that your FTP program displays incorrectly!
If there's a directory on your site that gets modified often, such as a directory that was generated by a caching plugin, you can add a hide command into the address bar, as follows:
If you want to hide more than one folder, simply add a comma, like so:
Download it here.
Download All
A package containing all four scripts can be downloaded here.
Disclaimer
For obvious reasons, I recommend deleting these scripts from your server as soon as you use them.
I certainly can't be held responsible for anyone who creates a list of all files and directories on their entire website … and leaves it open to the public. 😉
Enjoy!
Cassie Crudo
How can I set up / go to “then go to the appropriate addresses in your browser.”? I see something referenced in the original source, but not in these updated scripts to update to reference my own site. Thanks!
Jody Hatton
As an example, the first file would be accessed like this:
https://www.yourwebsite.com/file_list_1_structure_order.php
Userakos
Thanks! I have bookmarked the page.
Userakos
Very useful! Good job and thank you.
Colin M
Hi
Excellent Work.
Have just made a very minor mod to file_list_4_sort_by_date.php line 94
Presently reads
echo “File listing, sorted by size (descending order):”;
So corrected the to and changed text to be more appropriate
echo “File listing, sorted by date (most recent first):”;
Blupace
Hey, great work and thanks for sharing..
The scripts work fantasticly… Stay awesome 🙂