Way to automatically convert links after import?

  • I’ve just imported a blog (from powerblogs), and it mainly worked fine, but all of the internal links (between one post and another) are of the form “foo.powerblogs.com/post.” The old blog is still there, but it’s going away soon. Is there a tool or way to basically check all the links on my blog and if it points to an old post, to convert it to the new post automatically? (I could do this by hand, but there are hundreds of links scattered across nearly a thousand posts).

    The blog I need help with is: (visible only to logged in users)

  • No there is not, and there is a substantial difference between the permalink structures and it would take a considerable bit of programming to do that safely.

    The existing: foo.powerblogs.com/post

    What it will be here: blogname.wordpress.com/YYYY/MM/DD/post/

  • I don’t know if it would take considerable programming. But it does take direct access to the post database (which I don’t think I have). The trick is that right now the posts with the internal links are still up.

    So if I run my (mythical) program on post X and it finds a link to foo.powerblogs.com/post.

    The program opens up an HTTP link and reads that post and gets the HTML. That will an internal link (to the title) which has a date. The date has to be converted to YYYY/MM/DD (not too hard). The HTML also gives me the title, which wordpress converted (during import) to it’s title.

    Example:http://gaming.powerblogs.com/posts/1256075674.shtml
    Inspection of the HTML source has a span with the date October 20, 2009 and the div for the title lists “Lou, I think I may have topped that game of Medici” … just replace spaces with dashes and you have the

    Lou, I think I may have topped that game of Medici

    Even if there are some weird rules, at worst I’m replacing a (soon-to-be-broken) link with a broken link….

    But this program would need a way to access my posts and modify them. I’m willing to write it, but I need to know the way to access the blog structure (presumably I could do it via an HTTP connection but there’s lots of scripts I don’t want to inspect to figure it out…

  • WordPress works from MySQL databases. You cannot access the databases here at wordpress.COM. You would have to work off of what is in the XML file. and run the program on that file. You also have to make sure and not change the main post permalinks themselves since that will be taken care of during the import. You need to make sure that you only change links within posts.

  • Ah, I get it. Export all of my wordpress posts to my local machine, run my program to convert that XML file, then re-import them (presumably deleting all the posts first). Is that what you mean?

    Thanks for the help, by the way.

  • The file, when you import it back into wordpress is going to have to be the same format as it is now – xml. You will have to work off of that file, and like I said, you are going to have to test for and not convert the post and page titles since wordpress will do that. You only want to convert the old URL’s internal to the posts and pages to new ones. The other thing is you are going to have to make sure that you convert them to exactly what wordpress will turn the titles/post URL’s into.

    If the above is what you mean, then yes that is what you will have to do. Don’t be surprised if it takes a few times to get it right, and each time you import and it doesn’t work right, then you will have to delete all posts and pages and start again.

  • You’re welcome, by the way.

  • Since I imported a nearly 5 year old blog, I have ~850 posts. Even if I use the bulk action to delete, that’s going to take a while. Is there a way to do a “Delete All” in a single action?

  • The topic ‘Way to automatically convert links after import?’ is closed to new replies.