0

I'm struggling with my recently imported posterous data. All the image urls in the imported posts looks like this:

http://getfile1.posterous.com/getfile/files.posterous.com/temp-2013-03-30/kBpHaviyoumcvCEHnGnrDfwHwmJIrnqrHrxhCnHwfBIHuDsxbemHlxwEwCdi/IMG_6870.jpg

Now I tried to search and replace them with the Search and Replace Plugin, but it looks like it doesn't work with placeholders like:

http://%.posterous.com/getfile/files.posterous.com/temp-2013-03-%/%/

Has anybody any idea how i can get an url like above into:

http://my.domain.com/wordpress/wp-content/uploads/2013/03/IMG_6870.jpg

I'm able to execute SQL as well, if this helps. Thank you very much!

  • If you have access to the database, you could do a search and replace there. – gdaniel Feb 24 '14 at 19:28
  • Yes but how do I search and replace in SQL with placeholders for getfileXand the temp-YYYY-MM-DDand the hash? – sspross Feb 24 '14 at 19:36
  • Have you already taken a look at other questions like yours? – kaiser Feb 24 '14 at 19:47
  • Yes I did, do you see one that helps me? – sspross Feb 24 '14 at 19:52
0

I coudn't solve it with a plugin or plain SQL, see this other question. Instead I exported all the posts with Tools > Data export > Wordpress and deleted the posts. Then I run this python script over the exported XML file and imported the update xml file again. Tadaa...

import re

p = re.compile(r'http://([^/]*)/getfile/files.posterous.com/([^/]*)/([^/]*)/([^/]*)')

f1 = open('input.xml', 'r')
f2 = open('output.xml', 'w')

for line in f1:
    f2.write(p.sub(r'http://my.domain.com/wordpress/wp-content/uploads/legacy/\4', line))

f1.close()
f2.close()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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