Using a File Analyser for WordPress Media Cleanup

Quick answer: A file analyser can help you inventory WordPress uploads by name, type, size, and duplicate candidates. Use it to build a review list, not an automatic deletion list. Back up the site, check whether each file is used in posts, pages, themes, or other systems, and remove only items whose role you have confirmed. “Unattached” in the Media Library is not proof that an image is unused.

Old WordPress sites accumulate uploads, resized versions, and images from abandoned drafts. A file listing can show what exists and where storage is going. It cannot tell you by itself whether a file is still visible to a reader. Treat the analysis as a way to narrow a manual check.

Start with a safe inventory

Export a list of files from the uploads directory or a hosting file manager without changing the originals. Keep the path, extension, byte size, and modified date. If the tool supports checksums, add one for each original file. Match files to WordPress media records where possible. Note the date and scope of the export so a later run can be compared fairly.

ColumnWhy it belongs in the review
Path and filenameIdentifies the exact file and any generated size suffix.
Type and sizeHelps find unexpectedly large originals and files that may need a better format or dimensions.
ChecksumFinds byte-identical duplicate candidates even when names differ.
Media IDConnects a file to its WordPress attachment record, if one exists.
Where usedRecords a checked post, page, theme element, email, or external link. Mark unknown until verified.
DecisionKeep, replace, investigate, or remove after a recoverable backup.

Do not group files by filename alone. Two files can share a name while containing different images, and two identical files can have different names. A checksum flags identical bytes, but even a true duplicate may have separate URLs that other pages use.

Read WordPress attachment status correctly

WordPress’s attachment documentation explains that a file uploaded through the Media Library may be unattached to a post at first. The Media Library lets you filter for unattached items. That filter describes a database relationship; it does not examine every theme setting, custom field, page builder, email, or direct file URL. Check actual usage before making a deletion decision.

WordPress also generates smaller image sizes for display. They may look like near duplicates in a directory. The WordPress Theme Handbook documents these generated sizes. Removing them outside WordPress can break a layout even while the original file remains. Review the media record and the page that uses it instead of deleting size variants by pattern.

Work from low-risk fixes to removal

  1. Fix presentation first. If a useful image is simply too large for its display size, create an appropriate replacement and check the page after updating it.
  2. Investigate duplicates. Compare the files and every URL that refers to them. Pick one canonical asset only when you can update the references safely.
  3. Check apparent orphans. Search published pages, drafts, theme settings, and known external uses. Record where you looked.
  4. Back up and test. Save the original files and database, remove a small confirmed set through the proper WordPress workflow, then check affected pages and restore if needed.

A tool that promises one-click cleanup still depends on what it can inspect. Ask whether it checks block content, featured images, custom fields, theme options, and files used outside WordPress. A missing reference in one scanner is evidence to investigate, not proof that deletion is safe.

Keep the two analyses separate

A file analyser reviews stored assets. A server log analyser reviews requests made to the site. Use the latter when the question is whether visitors or crawlers request a missing image or page. Our guide to analyzing website logs explains that workflow. Combining both views can help you decide whether a file cleanup actually solved a broken-link problem.

Frequently asked questions

How do you clean up a WordPress Media Library?

Make a backup, inventory uploads, identify likely duplicates or unused items, and verify actual usage in posts, pages, themes, and other systems. Remove only confirmed items through a recoverable workflow and check affected pages afterward.

Can you delete unattached images in WordPress?

Only after checking where they are used. “Unattached” describes whether a media item is attached to a post record; it does not prove the file is absent from a theme, custom field, page builder, email, or direct link.

How do you find duplicate files?

Group files by checksum to find byte-identical candidates, then compare their paths and URLs. A matching filename is not enough. Before removing a duplicate, find every place that uses its URL and update those references.

How do you find unused images in WordPress?

Start with the Media Library and a file inventory, then search post content, drafts, featured-image records, theme settings, and known external uses. If your tool cannot inspect a source of references, mark the image as unconfirmed rather than unused.

Should a file analyser delete WordPress images automatically?

No. Use it to produce a review list. Generated image sizes and files used by themes or direct URLs can look unused to a scanner. Verify references, back up the site, and test a small confirmed change before removing more files.