Best way to strip character entities ( etc)

I have a heap of images inside MovableType, on an old server. There are plenty which have character entities like %20 to represent spaces.

I’ve used some plugins to import the images and change the URLs inside posts, but while MT can deal with /my%20dog.jpg, WP just shows a 404.

Read More

Assuming there’s no way to get WP to display these images, and I have to rename them, what’s the best way to:

  • Rename all the files (strip out character entities)
  • Rename all the URLs referenced in posts

I’m a little bit stuck here and not sure what the best way of solving this would be, whether via SSH and SQL queries, or otherwise.

Related posts

Leave a Reply

1 comment

  1. You are going to need:

    1. Total Commander
    (or anything else that allows you to rename massive numbers of files)

    Probably the best file manager in the world (especially when it comes to handle uploads etc.), it’s not free but the trial version should do the job. Just select all these images (they could be anywhere within Total Commander and choose “Multi-Rename tool (CTRL+M)” from “File” Menu.

    In “Search for” field type: %20 then change it to anything you like within “Replace with” field (I guess the best choice would be: _).

    Get Total Commander from: http://www.ghisler.com/

    2. A simple SQL command.

    UPDATE wp_posts SET post_content = replace(post_content,”%20″,”_”);

    It just “scans” every post for %20 and then simply replaces it with _

    I hope it helps.