Find largest file in your WordPress uploads folder 1

If you run your own WordPress Site or host a clients WP site, its good to keep an eye on disk space, to avoid running out of space at the most inopportune time. One of the main causes of running out of  disk space is when you upload large media files , and over time, your uploads/ folder begins to have some pretty big bloat.

Here’s a simple one line script that you can use to get a nice file list of the largest files in your folder.

Get a List of Folder Size

To get the a sense of which folders are taking up the most space , do the following

  1. navigate to the root of your WordPress directory (via the Linux command line)
  2. Issue the command
    du -shc wp-content/*
  3. It should produce output similar to:
    4.0K    wp-content/advanced-cache.php
    2.0M    wp-content/cache
    4.0K    wp-content/index.php
    71M     wp-content/plugins
    19M     wp-content/themes
    4.0K    wp-content/upgrade
    2.4G    wp-content/uploads
    32K     wp-content/w3tc-config
    5.3M    wp-content/wflogs
    8.0K    wp-content/wp-cache-config.php
    16K     wp-content/wppa-depot
    8.0K    wp-content/wppa-pl
    2.5G    total

     

  4. If you want just to get a sense of just the uploads/ folder simply :
    du -shc wp-content/uploads/*

Find the largest file in a WordPress  directory

Sometimes you just want to find what file is the most largest files in your WordPress  site. use this command

sudo du -ah wp-content/ | sort -n -r | head -n 20

This should produce a listing in reverse order largest to smallest of files in your wp-content folder.

That’s it , this is just a little post to help wrangle a large unruly WordPress folder.. enjoy.

One comment on “Find largest file in your WordPress uploads folder

  1. Reply Json Jan 7,2021 7:13 pm

    Is there an automatic way to check for this?

Leave a Reply