Vote Charlie!

CSV file of Movable Type entries with duplicate titles

Posted at age 25.
Created . Edited .

On the off chance this might be useful to someone, here is a sample template to output a CSV formatted file with all the entries in a blog that have duplicate titles. In the first Entries block’s blog_ids modifier, replace the word “all” with a blog ID number, or remove the modifier altogether if you are publishing this template within the blog from which you are exporting entries.

<mt:Section regex_replace="/\n\s*\n/mg","\n">

  <mt:Entries blog_ids="all" limit="100000">
    <$mt:EntryTitle setvar="entry_title"$> 
    <$mt:EntryID setvar="entry_id"$>
    <mt:If name="entry_ids{$entry_title}">
      <$mt:Var name="entry_ids{$entry_title}" setvar="first_id"$>
      <$mt:Var name="duplicate_ids{$first_id}" function="push" value="1"$>
      <$mt:Var name="duplicate_ids{$entry_id}" function="push" value="1"$>
    <mt:Else>
      <$mt:Var name="entry_ids{$entry_title}" value="$entry_id"$>
    </mt:If>
  </mt:Entries>

entry_title,entry_id

  <mt:Loop name="duplicate_ids" sort_by="key reverse">
    <mt:Entries blog_ids="all" id="$__key__">
      <mt:Section strip_linefeeds="1">
"<$mt:EntryTitle replace='"','"'$>",
"<$mt:EntryID$>"
      </mt:Section>
    </mt:Entries>
  </mt:Loop>

</mt:Section>

Related: Creating a CSV export Movable Type template