custom-scripts/cam-ingest-mac.sh

112 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
###########################################################
# Name: Camera Ingest Script
# Author: voidf1sh (Skylar Grant)
# Environment: M1 MacBook Pro
#
# Mounts:
# Camera SD: /Volumes/NO NAME
# NAS: //GUEST:@192.168.0.2/media -- /Volumes/media or /Volumes/media-1
#
# Git: https://git.vfsh.dev/voidf1sh/custom-scripts
# File: cam-ingest-mac.sh
# Version: 0.0.1
###########################################################
# Some initial variables to work with
# Set the date for folder creation
CURRENT_DATE=$(date +%F)
SD_SRC_PATH="/DCIM/100MSDCF"
MAC_INGEST_PATH="/Users/voidf1sh/Pictures/Camera Ingest"
NAS_INGEST_PATH="/Camera Ingest"
# TODO: Move this to after initiating Mac->NAS Ingest
# Check if the NAS is mounted
if mount | grep -q "//GUEST:@192.168.0.2/media"; then
# Get the NAS mount point since it can vary
NAS_MOUNT_POINT=$(mount | grep "media" | awk '{print $3}' | grep -E '^/Volumes/media(-1)?$')
echo "NAS Mounted at $NAS_MOUNT_POINT."
else
echo "ERR: NAS Not mounted!"
exit
fi
# TODO: Maybe move this to after initiating SD->Mac Ingest
# Check if the SD card is mounted
if mount | grep -q "/Volumes/NO NAME"; then
# Get the SD Card mount point, this is static though
SD_MOUNT_POINT="/Volumes/NO NAME"
echo "SD Card Mounted at $SD_MOUNT_POINT."
else
echo "ERR: SD Card Not mounted!"
exit
fi
# Initial Prompt
# Bash allows for linebreaks in string literals and will
# break lines accordingly in the shell
echo -e "
[ Camera Ingest Script ]
This script is being run from: '$(pwd)'
Please enter an option from below:
[1] Create and open folders.
[2] Cleanup non-RAW images on camera.
[3] Camera->Mac Ingest
[4] Mac->NAS Ingest
[0] Exit
"
# Wait for input
read -p " Option: " opt
# Execute the correct commands based on input.
case "$opt" in
1)
# Create and open folders.
clear
echo "Sike, this does nothing right now."
;;
2)
# Cleanup non-RAW images on camera.
clear
echo "Traversing to Camera..."
cd "$SD_MOUNT_POINT/$SD_SRC_PATH"
echo "Removing JPG files..."
rm *.JPG
echo "Cleanup completed!"
cd -
;;
3)
# Camera->Mac Ingest
clear
echo "Beginning copy..."
echo "Copying JPGs..."
rsync -avz --progress "$SD_MOUNT_POINT$SD_SRC_PATH/"*.JPG "$MAC_INGEST_PATH/JPG/"
echo "Copying ARWs..."
rsync -avz --progress "$SD_MOUNT_POINT$SD_SRC_PATH/"*.ARW "$MAC_INGEST_PATH/ARW/"
echo "Ingest complete!"
open $MAC_INGEST_PATH
;;
4)
# Mac->NAS Ingest
;;
0)
# Exit the script
echo "!! Quitting !!"
sleep 0.4s
clear
exit
;;
*)
clear
echo "!! Invalid Option !!"
;;
esac
# Loop the script
exec ./backup.sh