fred voisin’s website

computer music producer, since 1989

.txt to .mm

mindmapping

Petit shell-script à développer pour convertir un fichier texte (.txt) hirérarchisé par indentation au format .mm (Freemind)

#!/bin/bash
# txt2mm
# fred voisin, 2013

file=$1
out=`echo $file |cut -d "." -f 1`
echo "generation de $out.mm..."
cat $file |gsed -e '/^[ ]*$/d' -e 's/^/ /' | unexpand -t 1 > $file.0.tmp
head -n 1 $file.0.tmp |sed 's/^[ ]*//' > $file.tmp
n=`cat $file.0.tmp |wc -l |sed 's/^/-1+/' |bc`
tail -n $n $file.0.tmp |gsed 's/ /\t/' >> $file.tmp
text-to-freemind $file.tmp > $out.mm
rm $file.0.tmp $file.tmp
echo done