    #!/bin/sh
    #
    # SVG prep:
    #
    # if you have screen mockups in an SVG, draw a rectangular object/frame
    # around each screen you'd like to export. give each frame an id of
    # 'screen-$NAME', where $NAME is the name of the mockup. For example,
    # a frame with id="screen-main-menu" from an SVG with the name
    # '01_mockups.svg' will be exported to a PNG with the name:
    #
    # 01_mockups-main-menu.png
    #
    # input:
    #
    # name of SVG file
    #
    # output:
    #
    # any objects with an id of screen* will be exported into a PNG
    # subdirectory from where the script is run
    #
     
    if [ ! -e "PNG" ] ; then
    mkdir PNG
    fi
     
    # Get screen* IDs:
    sed -n '/id="spin\([^"]*\)"/s/.*id="\([^"]*\)".*/\1/gp' "$1" |
    # create export command for each screen:
    while read id
    do
    echo "$1" "--export-png='PNG/$(basename $1 .svg)-$(basename $id spin-).png'" "--export-id='$id'"
    done |
    # pipe to them to the inkscape shell
    inkscape --shell
     
    echo


