improve camera import script
This commit is contained in:
parent
6d65beff8f
commit
8336ffdacf
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
export CAM_SRC="/run/media/$USER/disk/"
|
export CAM_SRC="/run/media/$USER/disk/"
|
||||||
|
export CAM_PIC_SRC="$CAM_SRC/DCIM/100MSDCF"
|
||||||
|
|
||||||
# TODO: this is actually garbage lol, when importing pictures we should sort them
|
# TODO: this is actually garbage lol, when importing pictures we should sort them
|
||||||
# by their metadata, not by todays date and CERTAINLY not in an env variable which could
|
# by their metadata, not by todays date and CERTAINLY not in an env variable which could
|
||||||
|
|
|
@ -1,18 +1,38 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
# TODO: offer to clear camera storage
|
# copy photos with exif data on them into a date-structured directory hierarchy
|
||||||
|
|
||||||
src=$CAM_SRC
|
# source and destination locations
|
||||||
pic=$CAM_PIC
|
srcdir="$CAM_PIC_SRC"
|
||||||
|
picdir="$(xdg-user-dir PICTURES)/cam"
|
||||||
|
|
||||||
if [ "$#" -eq 2 ]; then
|
start=1
|
||||||
srcdir=$1
|
total=`ls $srcdir | wc -l`
|
||||||
bkpdir=$2
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ ! -d $srcdir ] && echo "$srcdir not found" && exit 1
|
for f in `ls $srcdir`
|
||||||
[ ! -d $bkpdir ] && echo "$bkpdir not found" && exit 1
|
do
|
||||||
|
progress="$start/$total"
|
||||||
|
start=$((start+1))
|
||||||
|
|
||||||
rsync --update --recursive --human-readable --progress $srcdir $bkpdir
|
src="$srcdir/$f"
|
||||||
|
|
||||||
|
# get the exif create date and turn it into a filepath
|
||||||
|
datestr=`exiftool -CreateDate "$src"`
|
||||||
|
datedir=`echo "$datestr" | awk '{ gsub(":","/",$4); print $4; }'`
|
||||||
|
datedir="$picdir/$datedir"
|
||||||
|
|
||||||
|
# make sure the destination exists
|
||||||
|
[ ! -d $datedir ] && mkdir -p $datedir
|
||||||
|
|
||||||
|
dest="$datedir/$f"
|
||||||
|
|
||||||
|
# if the file exists, don't overwrite
|
||||||
|
if [ -f $dest ]; then
|
||||||
|
print "[$progress] skipping $src->$dest: destination file already exists"
|
||||||
|
else
|
||||||
|
print "[$progress] sync $src -> $dest"
|
||||||
|
rsync $src $dest
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue