Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Bash source code: Copy video files from Cycliq Fly6 and Sony HDR-AS30V action cameras to NAS drive
#!/bin/sh
thisdate=$(date --rfc-3339=date)
echo Date is $thisdate
date
# MicroSD cards not automounted
as30v=/mnt/AS30V
fly6=/mnt/Fly6
sudo mount -o uid=ed /dev/sdb1 /mnt/AS30V/
sudo mount -o uid=ed /dev/sdc1 /mnt/Fly6/
# IOmega NAS defined as /mnt/video in fstab
sudo mount /mnt/video
mkdir /mnt/video/$thisdate
rsync -ahu --progress $as30v/MP_ROOT/100ANV01/ /mnt/video/$thisdate &
pid1=$!
rsync -ahu --progress $fly6 /mnt/video
date
rc2=$?
echo Fly6 RC is $rc2
echo Waiting for $as30v
wait $pid1
rc=$(( $rc2 + $? ))
date
echo Overall RC: $rc
if [ $rc -eq 0 ] ; then
echo Fix capitalized extensions
find /mnt/video -name \*AVI -print0 | xargs -0 rename -v -f 's/AVI/avi/'
find /mnt/video -name \*MP4 -print0 | xargs -0 rename -v -f 's/MP4/mp4/'
find /mnt/video -name \*THM -print0 | xargs -0 rename -v -f 's/THM/thm/'
echo Space remaining on NAS drive:
df -h /mnt/video
echo Remove files on AS30V
rm $as30v/MP_ROOT/100ANV01/*
echo Unmount cards and NAS
sudo umount $as30v
sudo umount $fly6
sudo umount /mnt/video
else
echo Whoopsie: $rc
fi
Owner

ednisley commented May 14, 2017

More details on my blog at http://wp.me/poZKh-6Lj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment