Migrating Drupal 6 'sites/default/files' directory to 'sites/sitename.com/files'

Profile picture for user Phil Frilling
By Phil Frilling, 8 August, 2012
Just wanted to post these instructions for my own sanity, and so I wouldn't lose them as I've used them numerous times over the past year. Thanks Jeff for the original post: http://www.midwesternmac.com/blogs/geerlingguy/moving-your-drupal-files…

Steps to change a Drupal 6 database to use a new files directory

  1. Update the files table (which is used by the system as well as imagecache): UPDATE `files` SET `filepath` = REPLACE(`filepath`, `sites/OLDDOMAIN/files/`, `sites/NEWDOMAIN/files/`);
  2. Update the boxes table (which is used for all the block content): UPDATE `boxes` SET `body` = REPLACE(`body`, `sites/OLDDOMAIN/files/`, `sites/NEWDOMAIN/files/`);
  3. Update the node_revisions table (all the node content is in here... you'll need to update both the body and the teaser fields): UPDATE `node_revisions` SET `body` = REPLACE(`body`, `sites/OLDDOMAIN/files/`, `sites/NEWDOMAIN/files/`); UPDATE `node_revisions` SET `teaser` = REPLACE(`teaser`, `sites/OLDDOMAIN/files/`, `sites/NEWDOMAIN/files/`);
  4. Update the users table 'picture' value (if you're using user pictures): UPDATE `users` SET `picture` = REPLACE(`picture`, `sites/OLDDOMAIN/files/pictures/`, `sites/NEWDOMAIN/files/pictures/`);