if you want to hardcode the img src changes, this would be the function for you; wp_update_post( $post ); coupled with a loop that goes through every post and post_type that you want to affect, and using preg_replace to replace the src url's.
assign the template to a page, load the page whenever you want to update the src url's, delete the page whenever you don't want to allow others to run the code.
the grep_replace() search/replace patterns would look something like this:
search: (<img [^>]*?src=['"]https?://)www\.sitename\.com
replace: $1cdn.sitename.com
or more specifically:
search: (<img [^>]*?src=['"]https?://)www(\.sitename\.com/wp-content/uploads/)
replace: $1cdn$2
even though wp_update_post() creates a revision automatically if case you need to reverse the change, backup the database before you load the page.
I'd test the loop, wp_update_post() and preg_replace() combination on a limited found set of posts first, possibly specifying the subject posts' IDs in an array and stepping through that array.
an additional option might be to create a new temporary category 'CDN Updated' and assigning the new category to each post as you update it. you could then omit any posts with this category term from future update queries. the one small disadvantage of this is that even if you later delete the category, the values would still be saved for each post in the db (correct me if I'm wrong).
cheers,
Gregory