Home
Projects
Sitemap
About

How to convert from many filetypes into Plucker pdb format

I like to read. Since I am (still) a poor student struggling for my daily bread (and sleep), I can't buy books. I also (TODO)

,#!/bin/bash

pluck () {
    local docdir=$(dirname "$2")
    local filename=$(basename "$2")
    local abspath=$(cd "$docdir" && pwd)
    plucker-build -f "$1" "file://${abspath}/${filename}"
}

if [[ -z $1 || -z $2 ]]; then
    echo "pluck-palm <Input file> <Document name>"
    exit 1;
fi;

inputfile="$1"
inputbase=$(basename "$1")
docname="$2"
tempfile=""

if [[ ! -d "$docname" ]]; then
    mkdir "$docname";
fi

case "$inputfile" in
    *.pdf)
        tempfile="$docname/${inputbase%%.pdf}.html"
        pdftohtml -noframes "$inputfile" "$tempfile"
        ;;
    *.rtf)
        tempfile="$docname/${inputbase%%.rtf}.html"
        outputfile=$(basename "$tempfile")
        cp "$inputfile" "$docname/"
        (cd "$docname";
            unrtf --html "$inputbase" > "$outputfile";
            rm "$inputbase")
        ;;
    *.lit)
        clit "$inputfile" "$docname"
        read -p "Please select file to pluck: " -e tempfile
        ;;
    *.zip)
        unzip "$inputfile" -d "$docname"
        read -p "Please enter file to pluck: " -e tempfile
        exec pluck-palm "$tempfile" "$docname"
        ;;
    *.rar)
        unrar x "$inputfile" "$docname"
        read -p "Please enter file to pluck: " -e tempfile
        exec pluck-palm "$tempfile" "$docname"
        ;;
    *.html)
        tempfile="$inputfile"
        ;;
    *.htm)
        tempfile="$inputfile"
        ;;
    *.jpg)
        unrar e "$inputfile" "$docname"
        read -p "Please enter file to pluck: " -e tempfile
        exec pluck-palm "$tempfile" "$docname"
        ;;
    *.txt)
        tempfile="$docname/temp.html"
        txt2tags -o "$tempfile" -t html --encoding iso-8859-1 "$inputfile"
        ;;
esac;

pluck "$docname" "$tempfile"
rm -rf "$docname"  

Autor: Jan Seeger <jan.seeger@thenybble.de>

Datum: 2010-09-08 12:49:25 CEST

HTML generated by org-mode 6.19b in emacs 22