summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul C. Buetow (mars.fritz.box) <paul@buetow.org>2014-05-07 11:02:41 +0200
committerPaul C. Buetow (mars.fritz.box) <paul@buetow.org>2014-05-07 11:02:41 +0200
commit15e73417d066343b721b1c07e8b73a1abe17f28b (patch)
treef59ee4fc1d4caa3022f0e342552914407f9a2e00 /src
parent4ca143713c90a020fa3a3864f3d7acbdfe7c42cf (diff)
sub-directories are not flatten anymore
Diffstat (limited to 'src')
-rwxr-xr-xsrc/photoalbum.sh42
1 files changed, 15 insertions, 27 deletions
diff --git a/src/photoalbum.sh b/src/photoalbum.sh
index e467aeb..fda18e1 100755
--- a/src/photoalbum.sh
+++ b/src/photoalbum.sh
@@ -3,12 +3,12 @@
# photoalbum (c) 2011 - 2014 by Paul C. Buetow
# http://photoalbum.buetow.org
-declare -r ARG1="${1}"; shift
-declare RC="${1}" ; shift
-
declare -r VERSION='PHOTOALBUMVERSION'
declare -r DEFAULTRC=/etc/default/photoalbum
+declare -r ARG1="${1}" ; shift
+declare RC="${1}" ; shift
+
if [ -z "${RC}" ]; then
RC="${DEFAULTRC}"
fi
@@ -84,34 +84,20 @@ function template() {
function scale() {
cd "${INCOMING_DIR}" && find ./ -type f | sort | while read photo; do
photo=$(sed 's#^\./##' <<< "${photo}")
+ destphoto="${DIST_DIR}/photos/${photo}"
+ destphoto_nospace=${destphoto// /_}
- if [ ! -f "${DIST_DIR}/photos/${photo}" ]; then
- # Flatten directories / to __
- if [[ "${photo}" =~ / ]]; then
- destphoto="${photo//\//__}"
- else
- destphoto="${photo}"
- fi
-
- destphoto_nospace=${destphoto// /_}
-
- if [[ ! -f "${DIST_DIR}/photos/${destphoto}"
- && ! -f "${DIST_DIR}/photos/${destphoto_nospace}" ]]; then
+ dirname=$(dirname "${destphoto}")
+ [ ! -d "${dirname}" ] && mkdir -p "${dirname}"
- echo "Scaling ${photo} to ${DIST_DIR}/photos/${destphoto}"
-
- convert -auto-orient \
- -geometry ${GEOMETRY} "${photo}" "${DIST_DIR}/photos/${destphoto}"
- else
- echo "Not scaling ${photo}, destination already exists"
- fi
+ if [ ! -f "${destphoto_nospace}" ]; then
+ echo "Scaling ${photo} to ${destphoto_nospace}"
+ convert -auto-orient \
+ -geometry ${GEOMETRY} "${photo}" "${destphoto_nospace}"
+ else
+ echo "Not scaling ${photo} to ${destphoto_nospace}, already exists"
fi
done
-
- echo 'Removing spaces from file names'
- find "${DIST_DIR}/photos" -type f -name '* *' | while read file; do
- rename 's/ /_/g' "${file}"
- done
}
function makedist() {
@@ -150,6 +136,8 @@ function makedist() {
if [ ! -f "${DIST_DIR}/thumbs/${photo}" ]; then
echo "Creating thumb for ${photo}";
+ dirname=$(dirname "${DIST_DIR}/thumbs/${photo}")
+ [ ! -d "${dirname}" ] && mkdir -p "${dirname}"
convert -geometry x${THUMBGEOMETRY} "${photo}" \
"${DIST_DIR}/thumbs/${photo}"
fi