43 lines
1.2 KiB
Bash
Executable file
43 lines
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
#Config file
|
|
cfg="$HOME/.config/sd-script.config"
|
|
if [ ! -f $cfg ]; then
|
|
touch $cfg
|
|
read -p "Where do you want to save your photos? [directory]: " destprompt
|
|
echo "destdir='$destprompt'" >> $cfg
|
|
read -p "Do you use sudo or doas?: " admin
|
|
echo "doso='$admin'" >> $cfg
|
|
fi
|
|
source $cfg
|
|
|
|
#Constant vars
|
|
sd_uuid="3735-3761"
|
|
mntpoint="/mnt/nikon"
|
|
srcdir="$mntpoint/DCIM/100_____"
|
|
|
|
#Colors
|
|
GREEN="\e[32m"
|
|
RED="\e[31m"
|
|
YELLOW="\e[33m"
|
|
ENDCOLOR="\e[0m"
|
|
|
|
#Copying locally
|
|
$doso mkdir $mntpoint #&> /dev/null
|
|
if $doso mount -U $sd_uuid $mntpoint; then
|
|
echo -e "[✅]$GREEN Mounted SD successfully$ENDCOLOR"
|
|
else echo -e "[❌] $RED Failed to mount SD$ENDCOLOR" && exit 1;
|
|
fi
|
|
|
|
mkdir $destdir &> /dev/null
|
|
echo -e "You have $YELLOW$(ls -l $srcdir/*.JPG | wc -l) JPG files$ENDCOLOR and $YELLOW$(ls -l $srcdir/*.NEF | wc -l) NEF files$ENDCOLOR."
|
|
|
|
|
|
if rsync -rvu --ignore-existing --info=progress2 $srcdir/ $destdir/pics-$(date '+%d-%b-%Y')/; then
|
|
echo -e "[✅]$GREEN Copying successful.$ENDCOLOR"
|
|
else echo -e "[❌] $RED Operation failed.$ENDCOLOR" && exit 1; fi
|
|
|
|
echo -e "Files from SD card will be removed in 3 seconds. If you don't want to delete files, press ctrl+C now."
|
|
sleep 3
|
|
$doso chown -R $USER:$USER $srcdir/
|
|
rm -fv $srcdir/*
|
|
exit 0
|