Is it possible to export all drafts in MovableType?
September 9, 2008 11:27 AM   Subscribe

MovableTypeFilter: Is there a way to export all unpublished entries (drafts)? It would be a million times easier for me to go through them all offline rather than one at a time with MT's cumbersome interface. I'm running MT 4.21. Even challenging solutions are helpful.

Over the years, my MovableType database has become littered with tons of unpublished drafts. So many, in fact, that they've become a lost cause. Many of these are crap ideas to be tossed, but there are a few unfinished gems scattered among them. What I'm hoping to do is export all drafts, and then delete them all. Then, offline, I'd scan through them to find the 5% that's worth salvaging. The offline part is easy... but exporting those drafts seems to be impossible.

I'm open to creative solutions here. Any ideas? How do you deal with all of your unpublished drafts?
posted by 2oh1 to Computers & Internet (7 answers total) 1 user marked this as a favorite
 
Could you dig into the MySQL tables of your database with phpMyAdmin or whatever administration tool your web host provides? I haven't delved under the hood of MT since they were using those Berkeley flat file things but assuming a straightforward table structure you could just export all rows where the column for Publish Status (or whatever) = Draft.

The exported file could be cracked open in a text editor or a spreadsheet and you could have at it to your heart's content.
posted by bcwinters at 12:24 PM on September 9, 2008


Response by poster: Good question. I'v never dabbled with MySQL beyond setting up databases, and that's done using my webhost's control panel. Beyond that, I'm clueless - but definitely going to look into it.
posted by 2oh1 at 12:32 PM on September 9, 2008


Best answer: I'm assuming you're not confortable rummaging around a database or you'd have done that already, so:

There's several steps here, but it goes faster than it looks.
  • Create a new blog, which I'll call "Blah;" give it some random-looking publishing directory to make sure it won't conflict with anything.
  • Grab the Transfer plugin. (This link will build a zip archive for you, but wanted you to know what you were getting.) Upload the stuff inside the plugins directory to your installation's plugins directory.
  • Go to your blog's entry listing, filter for status as "unpublished." Click the top-most checkbox to select all. In the "More actions..." drop-down, select "Transfer Entries," select Blah as the target on following screen.
  • Switch to Blah's entry list. Select all and click Publish at top.
  • Export this blog.
  • Delete Blah. Never speak of it again.
Alternately, you can skip the export, read through this blog's archives and transfer back the entries you want to keep before deleting Blah.

As a side note, in case someone finds that plugin enticing, I do not recommend Transfer for general use right now. It's unfinished(to put it lightly), but none of its problems are at issue with entries that were never published in the first place.
posted by Su at 12:33 PM on September 9, 2008


If you're even remotely comfortable with Perl, MT's API is very easy to use.

#!/usr/bin/perl

use lib qw(/path/to/your/cgi-bin/mt/lib /path/to/your/cgi-bin/mt/extlib);
use MT;
use MT::Entry;

my @entries = MT::Entry->load({blog_id => 1, status => 1}); # change blog_id as appropriate
for my $entry (@entries) {
print $entry->title, "\n";
print $entry->text, "\n";
print "-----/n";
}


When you're sure you have everything saved, replace the inside of the for loop with $entry->remove.

If you have such an overwhelming number of draft entries as to challenge your machine's memory, the above would need to be rewritten with load_iter instead of load, which complicates the removal a little. See the docs.
posted by Zed_Lopez at 12:40 PM on September 9, 2008 [1 favorite]


Response by poster: I've got about 250 drafts. Sadly, I'm absolutely clueless when it comes to perl, which is the main reason why I use MovableType instead of Wordpress. I design in html and then add MT tags/code appropriately inside the html code.

Su's idea sounds quite promising! I'll look into that after lunch.
posted by 2oh1 at 1:06 PM on September 9, 2008


Response by poster: That "Transfer" plugin is an odd one. I installed it, but it didn't show up in my MT plugins list - and yet it seems to have worked like a charm. I've got what I wanted - a huge text file consisting of all of my unpublished entries. It'll be so much faster to scan through that big long file and copy/paste ideas to save than it would be to load page after page in MovableType. In just the first look through the text file, I already found an old post worth finishing.

Problem solved!

Thanks!
posted by 2oh1 at 1:49 PM on September 9, 2008


Thanks for the great answer, Su, and sorry for the frustration 2oh1! I work with the MT team and I'll be honest -- I hadn't heard this particular request before. But I've made a note, and perhaps we can figure out a way to make this easier.

I was thinking there might also be a way to do this through MT's templating system, but Su would have pointed that out if it existed, I'm sure. :)
posted by anildash at 2:38 PM on September 9, 2008


« Older What game am I thinking of?   |   Who to file a complaint with for a problem with a... Newer »
This thread is closed to new comments.