Take the 2-minute tour ×

I've changed my wordpress default upload directory from:


I'm a bit stumped on the proper sql syntax to replace /files/year/month/ with /images/.

Using phpmyadmin, I selected the correct db, selected the correct table, and searched/found what needs to be changed using this sql:

FROM  `wp_postmeta` 
WHERE  `meta_value` 
LIKE  '%/files/%/%/%'

Now I need to REPLACE everything FROM wp_postmeta WHERE meta_value LIKE %/files/%/%/ WITH /images/

share|improve this question
add comment

3 Answers

Rather than doing it that way, WordPress provides the facility to change the upload folder using the wp-config.php file.

Basically you set WP_CONTENT_DIR for the server location and WP_CONTENT_URL for the URI's to be based on.

share|improve this answer
add comment

Another option is to use the following settings: update_option('uploads_use_yearmonth_folders', 0); update_option('upload_path', 'images');

share|improve this answer
add comment

I'd recommend the plugin WP Migrate DB for this. That's the easy way.

If your stuck on doing it the hard way, you could either run a query using REPLACE() for each path you want to replace (the function does not allow wildcards) or try something like this.

share|improve this answer
add comment

Your Answer


