#!/bin/bash

# this bash script creates all example files and directories that are
# part of the createPhotoWebPages documentation:

# restore example images:
cp -r images-original images

# run createPhotoWebPages with scan option:
../../createPhotoWebPages_en.pl -verbose                 \
                                -scan                    \
                                -order name              \
                                -rename -ext -prefix     \
                                selection-after-scan.txt \
                                ./images

# save images after scan:
cp -r images images-after-scan

# copy and patch selection file:
cp selection-after-scan.txt selection-before-rename.txt
patch selection-before-rename.txt patch-selection-before-rename.txt

# re-run createPhotoWebPages and create images and HTML pages:
../../createPhotoWebPages_en.pl -verbose                    \
                                selection-before-rename.txt

# save results in separate directory:
mkdir pages-before-rename
cp index*.html Slideshow.txt pages-before-rename
cp -r html pages-before-rename
cp -r images pages-before-rename

# copy and patch selection file:
cp selection-before-rename.txt selection-after-rename.txt
patch selection-after-rename.txt patch-selection-after-rename.txt
# preserve selection file (overwritten during script execution):
cp selection-after-rename.txt selection-after-rename-orig.txt

# re-run createPhotoWebPages and rename and rotate images:
../../createPhotoWebPages_en.pl -verbose                    \
                                -rename                     \
                                selection-after-rename.txt

# save results in separate directory:
mkdir pages-after-rename
cp index*.html Slideshow.txt pages-after-rename
cp -r html pages-after-rename
cp -r images pages-after-rename

# create two new files and patch new selection files:
cp selection-after-rename.txt my-selection.txt
patch my-selection.txt patch-my-selection.txt
cp my-selection.txt selection-web-ready.txt
patch selection-web-ready.txt patch-selection-web-ready.txt

# create new web-ready target directory:
mkdir ./web-ready-pages/

# re-run 2nd example:
../../createPhotoWebPages_en.pl -verbose          \
                                selection-web-ready.txt

# run final state:
../../createPhotoWebPages_en.pl -verbose          \
                                my-selection.txt

# finished.