Posts Tagged ‘tags’

Fix Moveable Type Export with Metatag TAGS instead of KEYWORDS

// October 26th, 2008 // 2 Comments » // linux, wordpress

Sometimes a Moveable Type export puts the tags in a Metatag field called TAGS. Sadly this kind of export file does not preserve the keywords/tags when it is imported in Wordpress. Here is a little fix to get these TAGS converted to KEYWORDS.

cat original.txt | sed '/^TAGS/s/ /,/ig' | sed '/^TAGS/s/"//ig' > converted1.txt ;let lines=`cat converted1.txt|wc -l`; let lines=`expr "$lines" : '\([0-9]*\)'`; for i in `seq 1 $lines`; do line=`head -n $i converted1.txt | tail -n 1`; istag=`echo $line|grep -E "^TAGS:"|wc -c`; if [ "$istag" -gt 0 ]; then tags=`echo $line|sed 's/TAGS: \\(.*\\)/\\1/g'`; echo $tags; fi; iskeyword=`echo $line|grep -E "^KEYWORDS:"|wc -c`; if [ "$iskeyword" -gt 0 ]; then let tagline=($i+1); fi; if [ "$i" == "$tagline" ]; then echo $tags; tags=""; tagline=0; else echo $line; fi; done > converted.txt