#!/bin/bash -e SOURCE=${1:-/mnt/sd} STATIC=${2:-/home/hendry/media/static/$(date --iso-8601)/} echo Copying files from $SOURCE to $STATIC # Prepare mkdir $STATIC 2> /dev/null || true for i in $(find $SOURCE -type f -iname "*.jpg" -o -iname "*.thm") do rsync -i $i $STATIC done # Cleanup rmdir $STATIC 2> /dev/null || true # delete dir if empty