title: Delete Wordpress media in database after FTP delete
body: <p>Through the FTP I've deleted my 2020 uploads folder and several subfolders of the 2021 folder. This because the Media library contained 250.000 images. The only problem is that those images still exist in the database.</p>
  <p>I've got this link that explains how to delete those rows: <a href="https://www.h3xed.com/web-development/wordpress-media-library-database-rows-and-tables" rel="nofollow noreferrer">https://www.h3xed.com/web-development/wordpress-media-library-database-rows-and-tables</a></p>
  <pre><code>DELETE FROM `wp_posts` WHERE `post_type` = &quot;attachment&quot;;
  DELETE FROM `wp_postmeta` WHERE `meta_key` = &quot;_wp_attached_file&quot;;
  DELETE FROM `wp_postmeta` WHERE `meta_key` = &quot;_wp_attachment_metadata&quot;;
  </code></pre>
  <p>But I don't want to delete all rows, but within a certain date range. Is this the correct addition to the query?</p>
  <pre><code>DELETE FROM `wp_posts` WHERE `post_type` = &quot;attachment&quot; AND DateField BETWEEN &quot;01/01/2020&quot; to &quot;01/08/2021&quot;;
  DELETE FROM `wp_postmeta` WHERE `meta_key` = &quot;_wp_attached_file&quot; AND DateField BETWEEN &quot;01/01/2020&quot; to &quot;01/08/2021&quot;;
  DELETE FROM `wp_postmeta` WHERE `meta_key` = &quot;_wp_attachment_metadata&quot; AND DateField BETWEEN &quot;01/01/2020&quot; to &quot;01/08/2021&quot;;
  </code></pre>