improve camera import script
This commit is contained in:
parent
6d65beff8f
commit
8336ffdacf
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
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
|
||||
# by their metadata, not by todays date and CERTAINLY not in an env variable which could
|
||||
|
|
|
@ -1,18 +1,38 @@
|
|||
#!/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
|
||||
pic=$CAM_PIC
|
||||
# source and destination locations
|
||||
srcdir="$CAM_PIC_SRC"
|
||||
picdir="$(xdg-user-dir PICTURES)/cam"
|
||||
|
||||
if [ "$#" -eq 2 ]; then
|
||||
srcdir=$1
|
||||
bkpdir=$2
|
||||
fi
|
||||
start=1
|
||||
total=`ls $srcdir | wc -l`
|
||||
|
||||
[ ! -d $srcdir ] && echo "$srcdir not found" && exit 1
|
||||
[ ! -d $bkpdir ] && echo "$bkpdir not found" && exit 1
|
||||
for f in `ls $srcdir`
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue