For unknown reasons, a recent VLC update caused it to ignore uppercase file extensions: MP4
and AVI
files no longer appear in its directory listings, while mp4
and avi
files do. The least-awful solution involved renaming the files after copying them:
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/'
Yup, that scans the whole drive every time, which takes care of stray files, manual tweaks, and suchlike. The THM
files are useless thumbnails; I should just delete them.
While I had the hood up, I listed the remaining space on the NAS drive and cleaned up a few misfeatures. I manually delete old video files / directories as needed, usually immediately after the script crashes for lack of room.
The Sony HDR-AS30V can act as a USB memory device, but it dependably segfaults the ExFAT driver; I now transfer its MicroSD card to an adapter and jam it into the media slot on the monitor, where it works fine.
Protip: always turn the AS30V on to verify the MicroSD card has seated correctly in its socket. Unfortunately, the socket can also hold Sony’s proprietary Memory Stick Micro cards (32 GB maximum capacity = roadkill), but the dual-use / dual-direction socket isn’t a snug fit around MicroSD cards. You (well, I) can insert a card so it looks fine, while sitting slightly canted and not making proper contact. The camera will kvetch about that and it’s easier to fix with the camera in hand.
I’ve disabled USB device automounting, as I vastly prefer to handle them manually, so the script asks for permission in order to mount the drives. The transfer requires about an hour, so I’ve extended the time the sudo
password remains active.
The script lets both cards transfer data simultaneously; the Fly6 generally finishes first because it produces less data. That produces a jumbled progress display and the script waits for both drives to finish before continuing.
The Bash source code as a GitHub Gist:
#!/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 |
Gotta love developers with sense of humor… I once found almost identical error handler in a production app for our client with one little twist, guy who wrote it didn’t include any additional info, so user ended up with just “Whoopsie!!!” in the error dialog. Very useful when thrown from a procedure that (on a good day) can go wrong in about 30 different way :)
I was developing some communications code once, and unbeknownst to me, my employer shipped it out to be deployed by the US Navy. I found out about it when I got an irate call from someone on a ship at sea who’d just gotten the error message “Can’t get a buffer to save my ass!”
“Developer”: that would not be me!
I’ve come to realize the Great Truth: never check for any error you can’t (or won’t) do anything about. [grin]
You joke but that’s probably practice number two I have to beat out of every new Oracle developer I get. For some reason they are ALWAYS taught to add exception blocks to their code but are NEVER taught what to actually do in them except mask the real error with ultimately unhelpful “ummm, there was some error dude, whatever, I’m gonna go and quit now”.
For those curious, practice number one is using cursors for everything and the kitchen sink :)