#!/bin/bash ########################################################################### # This script is for people who have drawings on a Sony PRS-600 and want # to convert those drawings to SVG for opening in Inkscape, GIMP, etc. # It may also work with "Notepad" drawings on the PRS-650 etc. # # Are there more elegant ways to do this? Yes. # Do I really care? Well, this works, so I don't care too much. # I know the first several lines of every drawing note file are # junk that needs to go, as well as several of the last lines. # So, I strip those off. # # I know xs1: needs to be gone from the file so # I delete all instances of it. # # So far, I end up with a working svg every time. # # The use is pretty simple, from a terminal you call the script # with an input filename of the note drawing you want to convert # and an optional output name. The script will default to a # output of the input filename with ".svg" tacked on the end # if you don't specify a different name. # # ./note2svg.sh [the prs-600 drawing note file] [optione output filename] # # Phillip J Rhoades 2022-02-15 ########################################################################### #--------------------------------------------- # Setting up some named variables # and either using the note filename # as a base for the output filename # or using one designated by the second # argument passed to the script #--------------------------------------------- notefile="$1" if [ -z "$2" ]; then #echo "Output file undefined. Defaulting to $notefile.svg"; outfile="$notefile.svg" else #echo "Output file is defined as $2"; outfile="$2" fi #------------------------------------------- # pop an xml header into the output first #------------------------------------------- echo '' >"$outfile" #-------------------------------------------------- # Trim and delete stuff that needs to go, # add back an that needs to be there, etc # to make a real SVG file. # Leave the last in place #-------------------------------------------------- # This opens the svg container echo '' >>"$outfile" # This gives the SVG a white background echo '' >>"$outfile" # this strips out stuff we don't need head -n -3 "$notefile" | tail -n +6 |sed 's/xs1\://g' >>"$outfile" # Give the user some feedback echo "Conversion of $notefile to SVG complete at $outfile"