sazli
Forum Replies Created
-
In case you haven’t got this solved, here’s how I did it (lazy unix way, but worked):-
1. Get the list of attachment URLs from the xml file (exported from wordpress.com), into a file ready to be wget-ed:-
# grep 'attachment_url' wp-exported.xml | sed 's/<wp:attachment_url>//g;s/<\/wp:attachment_url>//g' > attachments.txt2. Prepare a temporary directory on any web-reachable + shell accessible space (such as your target wordpress site):-
# cd /home/wordpress/public_html; mkdir attachments3. Download all attachments from wordpress.com to the temporary directory using wget (list of URLs in attachments.txt):-
# cd attachments; wget -t 0 -c -i attachments.txt4. Edit the xml file exported from wordpress.com, and do a global search and replace for the old files.wordpress.com URL, replacing it with your temporary folder:-
# vim wp-exported.xml
:%s/<wp:attachment_url>http:\/\/oldblog.wordpress.com\/[0-9]*\/[0-9]*/<wp:attachment_url>http:\/\/newblog.com\/attachments/g
:wq5. At your new wordpress site, re-import using the newly edited wp-exported.xml file. The import script should download the files off of your temporary directory without any ‘not respond’ errors.
6. In my case however, after successful import, in the new blog site, each post still loads images from the old wordpress.com blog. So I had to dump the local wordpress db, edit it, and do the following search replace commands:-
# mysqldump --databases newblog > newblog.sql
# vim newblog.sql
:%s/oldblog.wordpress.com\/[0-9]*\/[0-9]*/newblog.com\/wp-content\/uploads\/2010\/04/g
(Note that the last 2 numbers must be the year and month when your import was done i.e. current year & month).7. [You might not need to do this] In my wordpress.com site I had adjusted the medium size image setting (Settings -> Media) to 500×500, so I had to adjust the link in the new site to match the actual file name (since w=500 no longer works in the new site):-
:%s/\.jpg?w=500/-500x375.jpg/g
:wq
(If you need to do this, you need to peek inside your new site’s uploads directory to see the file name patterns and adjust the above command accordingly).8. Reimport the modified SQL file:-
# mysql < newblog.sqlThese are far from efficient (there must be a better way), but it worked for me, without dabbling with wordpress code.
Hope this helps! 🙂