Created
December 24, 2016 21:33
-
-
Save giantryansaul/88618738afd7de402ae6ec4bc8100c7d to your computer and use it in GitHub Desktop.
Nikon RAW photo transfer from remote to local. This script transfers the raw NEF file to a local working directory along with related JPG files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Nikon RAW photo transfer from remote to local. | |
# Created by: Ryan Saul | |
# | |
# I have a process of backing up all of my photos to a remote PC in the $REMOTE_BACKUP/pending directory so I can work on them later. | |
# This script transfers the raw NEF file to a local working directory. | |
# It then moves the NEF file to the $REMOTE_BACKUP/processed directory along with the related JPG (if it exists). | |
# | |
# Required: $REMOTE_BACKUP and $LOCAL_BACKUP set to their respective | |
# You can set these in your bashrc or right here in the script: | |
# | |
# REMOTE_BACKUP=<your remote backup directory> | |
# LOCAL_BACKUP=<your local backup directory> | |
SERVER=home | |
REMOTE_PENDING=$REMOTE_BACKUP/pending | |
REMOTE_PROCESSED=$REMOTE_BACKUP/processed | |
OPT1=$1 | |
TRANSFER_AMT=${OPT1:=10} | |
echo $(date) "Transferring $TRANSFER_AMT photo(s)" | |
echo $(date) Getting files to transfer | |
files_to_transfer=$(ssh $SERVER 'find '$REMOTE_PENDING' -type f -name "*.NEF" | head -n '$TRANSFER_AMT'') | |
for transfer in $files_to_transfer | |
do | |
transfer_subdirectory=$(basename ${transfer%/*}) | |
echo $(date) Ensuring subdirectory $transfer_subdirectory exists | |
ssh home 'mkdir '$REMOTE_PROCESSED'/'$transfer_subdirectory'' 2> /dev/null | |
echo $(date) Transferring file $transfer | |
scp home:$transfer $LOCAL_BACKUP | |
echo $(date) Moving transferred file from $transfer to $REMOTE_PROCESSED/$transfer_subdirectory | |
ssh home 'mv '$transfer' '$REMOTE_PROCESSED'/'$transfer_subdirectory'/' | |
echo $(date) Moving associated JPG if it exists | |
associated_jpg=${transfer%.NEF}.JPG 2> /dev/null | |
ssh home 'mv '$associated_jpg' '$REMOTE_PROCESSED'/'$transfer_subdirectory'/' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment