Doing it once is a task. Doing it four hundred times is a different problem with a different answer. These are the articles where the count is the difficulty.
WordPress Images
Clean Up WordPress Media Library Without Breaking Pages
An attachment is a row in wp_posts; its files sit somewhere else, and deleting one does not delete the other. What to measure before you start, why "unused" is so hard to prove, and the order of operations that keeps the site up.
WordPress Watermark: Which File Actually Gets Stamped
A watermark can go on the original, on the sub-sizes WordPress generates, or on top at display time. Only two of those put pixels in the file, and only one of them is reversible.
Image File Names: The Boring Detail That Breaks Things
WordPress renames every file you upload, using rules almost nobody has read. Here is what sanitize_file_name actually changes, why a name with an umlaut resolves on one host and 404s on another, and why core answers a collision by adding a number instead of overwriting. Clean your names in the browser first, because after the upload the name is a URL.
Core converts on upload through a single filter and ignores everything already in the library. Here is what that filter really covers, what regeneration adds, and why the uploads folder grows before it shrinks.
WordPress Duplicate Images: How to Find and Delete Them Safely
Uploading the same file twice gives you a numbered copy, not a match, because core only tests the file name against one directory. Here is how the duplicates get made, three detection passes ranked by what they actually prove, and a deletion order that will not break a live page.
Bulk Resize Images in WordPress Without Breaking the Library
Regenerating thumbnails and resizing the original are different jobs, and only one of them is irreversible. What the scaled pair actually costs you, how to measure it with read only commands, what a safe bulk resize has to do step by step, and why most sites should fix the upload threshold instead.
Regenerate Thumbnails in WordPress: What It Fixes and What It Leaves Behind
Regenerating thumbnails re-encodes every registered size from the original file. Here is when it is genuinely needed, what each WP-CLI flag really does, why --only-missing quietly keeps the old files, and the order that stops your uploads folder growing.