my wordpress has this setting for upload - .../uploads/{year}/{month}

However I noticed that some folders (like .../uploads/2023/06) have 30+ thousands files.

So I want to relocate them to new subfolder (like .../uploads/2023/06/21).

However the problems are:

  • file's link in posts
  • file in media library

Does any one has idea how to relocate files and make changes in post(s) & library at once (php code, plugin etc)?

Thanks for ideas.

Have a nice day.

1 Answer 1


You can move the files and use the Search & Replace plugin to easily change all occurrences of /uploads/2023/06 in your posts to /uploads/2023/06/21. Note: before using the plugin, I recommend you to make a backup from your database.

  • Thanks for idea. I solved it with wp_filesystem_direct::move() and update query with replace()
    – wpproguser
    Commented Jun 22, 2023 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.