initial copy from old project

This commit is contained in:
Marc Wäckerlin
2015-11-05 17:37:39 +00:00
commit c66d45d349
28 changed files with 5126 additions and 0 deletions

12
scripts/makefile.am Normal file
View File

@@ -0,0 +1,12 @@
## @id $Id$
## 1 2 3 4 5 6 7 8
## 45678901234567890123456789012345678901234567890123456789012345678901234567890
EXTRA_DIST = mvfotos.in
bin_SCRIPTS = mvfotos
dist_sysconf_DATA = mvfotos.conf
DISTCLEANFILES = mvfotos
MAINTAINERCLEANFILES = makefile.in

53
scripts/mvfotos.conf Normal file
View File

@@ -0,0 +1,53 @@
## @id $Id$
## 1 2 3 4 5 6 7 8
## 45678901234567890123456789012345678901234567890123456789012345678901234567890
# Configuration file for mvfotos, the script to move or copy
# configuration files from any source into a defined target and to
# distinguish and sort into subdirectories according to the file type.
# base path to move multimedia files
target=/var/data/familie
# number of distinguished file types (recognized by extention)
num=9
# default prefix for the file types if not given by option -p
prefix[1]=foto
prefix[2]=foto
prefix[3]=video
prefix[4]=video
prefix[5]=musik
prefix[6]=musik
prefix[7]=foto
prefix[8]=audio
prefix[9]=foto
# file name extensions to detect the file types
ext[1]="jpg png tif xcf jpeg"
ext[2]="jps"
ext[3]="mxf mts avi mov mpg mp4 mpg 3gp"
ext[4]="cpi"
ext[5]="wav"
ext[6]="mp3"
ext[7]="rw2"
ext[8]="3ga"
ext[9]="mpo"
# path that is added to target base path
path[1]="bilder"
path[2]="bilder3d"
path[3]="video"
path[4]="video/clipinfo"
path[5]="musik/raw"
path[6]="musik/familienkonzert"
path[7]="bilder/raw"
path[8]="musik/aufnahmen"
path[9]="bilder3d.mpo"
# file name extensions that contain exif information
exif="jpg jps mpo jpeg"
# number of the clipinfo file type, ${ext[$cpi]} must contain "cpi"
cpi=4

127
scripts/mvfotos.in Executable file
View File

@@ -0,0 +1,127 @@
#!/bin/bash -e
## @id $Id$
## 1 2 3 4 5 6 7 8
## 45678901234567890123456789012345678901234567890123456789012345678901234567890
# configuration ##########################################################
prefix="@prefix@"
test -e "@sysconfdir@/mvfotos.conf" && . "@sysconfdir@/mvfotos.conf"
test -e ~/.mvfotos && . ~/.mvfotos
# end of configuration ###################################################
if test -z "${target}" -o ! -d "${target}"; then
echo "Please configure $1 in " 1>&2
echo "@sysconfdir@/mvfotos.conf or in ~/.mvfotos" 1>&2
exit -1
fi
cmd="mv -n"
test=no
globalprefix=
globaltype=
while [ $# -gt 0 ]; do
if [ "$1" == "-c" ]; then
cmd="cp -n"
elif [ "$1" == "--test" ]; then
test=yes
elif [ "$1" == "-t" ]; then
globaltype="$2"
shift
elif [ "$1" == "-p" ]; then
globalprefix="$2"
shift
elif [ "$1" == "-h" ]; then
echo "$0 [-p prefix] [-c] file [...]]"
echo
echo "OPTIONS"
echo " -p prefix specify name prefix"
echo " -c copy instead ov move"
echo " -t type overwrite file name extension"
echo " --test test only"
exit 0
else
postfix=$(basename "$1" | tr '[:upper:]' '[:lower:]' | sed 's/[ ]/_/g')
type=${globaltype:-${postfix##*.}}
date=
if [ "${exif//${type}/}" != "$exif" ]; then
date=$(exif -t 0x132 "$1" | sed -n 's/.*Value: \([0-9]*\):\([0-9]*\):\([0-9]*\) \([0-9]*\):\([0-9]*\):\([0-9]*\)/\1\2\3-\4\5\6/p' | uniq)
if [ -z "$date" ]; then
date=$(exif -t 0x9003 "$1" | sed -n 's/.*Value: \([0-9]*\):\([0-9]*\):\([0-9]*\) \([0-9]*\):\([0-9]*\):\([0-9]*\)/\1\2\3-\4\5\6/p' | uniq)
fi
if [ -z "$date" ]; then
date=$(exiftool -FileModifyDate "$1" | sed -n 's/.*File Modification Date\/Time.*: \([0-9]*\):\([0-9]*\):\([0-9]*\) \([0-9]*\):\([0-9]*\):\([0-9]*\)[^0-9]*.*/\1\2\3-\4\5\6/p' | uniq)
fi
fi
if [ -z "$date" ]; then
date=$(stat -c%y "$1" | sed 's/\(....\)-\(..\)-\(..\) \(..\):\(..\):\(..\).*/\1\2\3-\4\5\6/')
fi
if [ -z "$date" ]; then
echo "**** $0: CANNOT EVALUATE: $1" 1>&2
shift
break
fi
year=$(echo "$date" | sed 's/\(....\)....-.*/\1/')
month=$(echo "$date" | sed 's/....\(..\)..-.*/\1/')
day=$(echo "$date" | sed 's/......\(..\)-.*/\1/')
if [ "$month" -lt 3 -o "$month" -eq 3 -a "$day" -lt 21 ]; then
season=winter
elif [ "$month" -lt 6 -o "$month" -eq 6 -a "$day" -lt 21 ]; then
season=fruehling
elif [ "$month" -lt 9 -o "$month" -eq 9 -a "$day" -lt 21 ]; then
season=sommer
elif [ "$month" -lt 12 -o "$month" -eq 12 -a "$day" -lt 21 ]; then
season=herbst
else
season=jahresende
fi
found=no
for ((i=1; i<=$num; ++i)); do
if [ "${ext[$i]//$type/}" != "${ext[$i]}" ]; then
found=yes
break
fi
done
if [ $found = "no" ]; then
echo "**** $0: UNKNOWN FYLE TYPE ($type): $1" 1>&2
shift
break
fi
path="${target}/${path[$i]}/${year}/${year}_${season}"
if test -z "$globalprefix"; then
prefix=${prefix[$i]}
else
prefix=${globalprefix}
fi
test -d "path" || mkdir -p "$path"
echo "$cmd $1 ${path}/${date}-${prefix}-${postfix}"
if test -e "${path}/${date}-${prefix}-${postfix}"; then
echo "WARNING: target already exists, ignored"
else
if test "$test" != "yes"; then
$cmd "$1" "${path}/${date}-${prefix}-${postfix}"
if which exiftran > /dev/null; then
if [ "${exif//${type}/}" != "$exif" ]; then
echo "exiftran -aip ${path}/${date}-${prefix}-${postfix}"
exiftran -aip "${path}/${date}-${prefix}-${postfix}"
fi
fi
fi
fi
clipinf="${1/STREAM/CLIPINF}"
clipinf="${clipinf%.*}.CPI"
if test -f "$clipinf"; then
path="${target}/${path[$cpi]}/${year}/${year}_${season}"
echo "$cmd $clipinf ${path}/${date}-${prefix}-${postfix%.*}.cpi"
if test -e "${path}/${date}-${prefix}-${postfix%.*}.cpi"; then
echo "WARNING: target already exists, ignored"
else
if test "$test" != "yes"; then
test -d "path" || mkdir -p "$path"
$cmd "$clipinf" "${path}/${date}-${prefix}-${postfix%.*}".cpi
fi
fi
fi
fi
shift
done