diff options
author | B Stack <bgstack15@gmail.com> | 2021-02-01 09:07:23 -0500 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2021-02-01 09:07:23 -0500 |
commit | a4481dc007ff202882b783ed4b36e03a8b4c1d05 (patch) | |
tree | 0f8b5ccb6ea5e966e8d517b07936479ef49b3516 /generate.sh | |
download | gallery-a4481dc007ff202882b783ed4b36e03a8b4c1d05.tar.gz gallery-a4481dc007ff202882b783ed4b36e03a8b4c1d05.tar.bz2 gallery-a4481dc007ff202882b783ed4b36e03a8b4c1d05.zip |
initial commit
Diffstat (limited to 'generate.sh')
-rwxr-xr-x | generate.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/generate.sh b/generate.sh new file mode 100755 index 0000000..c1caccf --- /dev/null +++ b/generate.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# File: generate.sh +# Author: bgstack15@gmail.com +# Startdate: 2021-01-24 +# Title: Generate symlink Forests +# Package: gallery +# Purpose: turn indir into a year/month set of symlinks at outdir +# History: +# Usage: +# Useful for running before sigal.bin. +# Reference: +# Improve: +# replace tildes in video filenames! +# rewrite in python +# Dependencies: +# exiftool + +test -z "${indir}" && export indir="${1}" +test -z "${outdir}" && export outdir="${2}" +{ test -z "${indir}" || test ! -d "${indir}" ; } && { echo "First parameter must be input path. Aborted." 1>&2 ; exit 1 ; } +{ test -z "${outdir}" || test ! -d "${outdir}" ; } && { echo "Second parameter must be output path. Aborted." 1>&2 ; exit 1 ; } +# strip trailing slashes +export indir="${indir%%/}" +export outdir="${outdir%%/}" +for tf in $( find "${indir}" ! -type d ! -name '*.sh' ! -name '*.git*' ! -name '.*.swp' ) ; +do + YM="$( exiftool -t -createdate "${tf}" | awk -F'\t' '{print $NF}' | awk -F' ' '{print $1}' | awk -F ':' 'BEGIN{OFS="/"} {print $1,$2}' )" + test ! -d "${outdir}/${YM}" && { + test -n "${DEBUG}" && echo "mkdir -p ${outdir}/${YM}" + test -z "${DRYRUN}" && mkdir -p "${outdir}/${YM}" + } + test -n "${DEBUG}" && echo "ln -s ${tf} ${outdir}/${YM}/" + test -z "${DRYRUN}" && ln -s "${tf}" "${outdir}/${YM}/" +done |