Thread: Request Merging journals
View Single Post
Old 07-26-2010, 02:51 PM   #1
ericvh
Edge User
 
Merging journals

The performance of the journal app with large journals has led me to work on daily journals and then merge them at some interval. The following script is useful to do the merging, usually I export a group of journals and then run this script over them which merges them into a single journal with tabnames equal to the original journal file names. It would be nice to have this (or something like this) available as a button on the Library screen when you select a group of journals.

#!/bin/bash

function trim
{
x=$(($1-1))
head -n $x /tmp/temp > /tmp/temp2
}

function convert
{
name=`echo $1 | sed s/.esj//g`
echo "<page width=\"396.00\" height=\"540.00\" tabname=\"$name\">"
gzcat $1 | tail +6 > /tmp/temp
lines=`wc -l /tmp/temp`
trim $lines
mv /tmp/temp2 /tmp/temp
#sed s/tabname=\"\"/tabname=\"$name\"/g /tmp/temp
cat /tmp/temp
rm /tmp/temp
}

function wrapper
{
echo "<?xml version=\"1.0\" standalone=\"no\"?>"
echo "<xournal version=\"0.4.2.1\">"
echo "<author>XXXXX</author>"
for ARG in $*
do
convert $ARG
done
echo "</xournal>"
}

wrapper $* | gzip -