About This
I am Michael Tyson, and I run A Tasty Pixel. I write on a variety of technology and software development topics as I travel around Europe in a motorhome.
-
Subscribe to updates 492 feed subscribers
Follow me on Twitter 964 followers
Our Products
Newsletter
Let us keep you informed about important updates, special offers, and new products. Just type in your email address below and hit enter to sign up!
-
Recent Posts
Topics
Audio Business Career Cocoa Code Data Debugging Demo Design Development Google Graphics Interface iPad iPhone Lifestyle Links Location Loopy Loopy HD Mac Maps Marketing Networking Optimisation PHP Scripts Security Shell Social Comment Software Talkie Talkie-for-Mac The Cartographer Travel Tutorial Twitter Update Utility Web WordPress WordPress Plugins WordPress Themes Workflow XCode




Re-organising/assembling uploads for WordPress
Migrating from Serendipity, I’ve had a few hiccups in data migration. It doesn’t help that I’m extremely OCD when it comes to data, so everything’s gotta be perfect.
I had a problem with the way my uploads (the resources linked into the blog) were organised from the old Serendipity days – all in one big ol’ folder – and wanted to re-arrange them the way WordPress does it, which is to arrange them into folders by year and month.
This is also useful if you’re changing your domain, or splitting up one blog into two. The entries link to the old domain/blog, and thus the alternative is to do keep the old site around or muck around with clever redirects.
My way’s neater.
So, I put together a script which goes through all posts, pulls out links to uploaded files, and moves/copies them into a better arrangement, fixing the link in the process. If it can’t find the files, it’ll use a ‘find’ command to attempt to locate them.
In case it’s useful to others, the script is here: reorganise-wp-media.php.zip
It goes in the WordPress webroot; put it there, then edit it to apply your settings. Give it a ‘dry run’ test, make sure all is well, then go for it. Beware, although I used it and it worked okay, I offer no guarantee that it won’t mangle your data, delete random files or eat your dog.
Related posts