I have snapshots (photos) that I load off my camera's memory card, and store in a folder. Sometimes I have videos, and occasionally plain audio too (the camera can record just sound).
Additionally, my wife, and kids have their point-and-shoots too.
I have a workflow where I dump the photos on to a designated folder on a linux samba share, and then run this script which identifies the photos, auto-rotates the portrait picturs, and renames them according to the date and time the picture was taken (rather than a sequential number from the camera).
This way, assuming the various cameras have the correct clock-time set, the different cameras all have photos that are named similar things (and can be sorted alphabetically to get them in chronological order too.
Notes:
- the jhead program the script calls will rename/rotate the photos, and the name will become something like:
Img20140217-164850.20.jpg
- the jhead also identifies that some pictures may have 'raw' partners, for example, my Nikon camera takes a picture called
DSC1234.JPG
and simultaneously the pictureDSC1234.NEF
(the raw photo). The commandjhead -aNEF -ft -autorot -n DSC*.JPG
will identify the JPG photo, strip the .JPG extensions, and, because there is also the-aNEF
argument, will rename the matching NEF file to the same base-name (Img*
) as the JPG.... in other words, for the filesDSC1234.JPG
andDSC1234.JPG
, the jhead program will produce, for example, bothImg20140217-164850.20.jpg
andImg20140217-164850.20.NEF
- the script deals with both Canon, and Nikon raw files (
RW2
andNEF
respectively)
The script is relatively simple, but has a fair amount of repetition. Any suggestions for how to improve it?
#!/usr/bin/tcsh -f
#cd /valuable/picxfer
# Do the .jpg first because the jhead program will write .jpg even for .JPG input.
echo 'Checking DSC*.jpg'
if ( `tcsh -f -c "ls -1 DSC*.jpg >& /dev/null" && echo yes` == "yes" ) then
jhead -anef -ft -autorot -n DSC*.jpg
else
echo no Nikon jpg files
endif
echo 'Checking DSC*.JPG'
if ( `tcsh -f -c "ls -1 DSC*.JPG >& /dev/null" && echo yes` == "yes" ) then
jhead -aNEF -ft -autorot -n DSC*.JPG
else
echo no Nikon JPG files
endif
echo 'Checking *.jpg'
if ( `tcsh -f -c "ls -1 p*.jpg >& /dev/null" && echo yes` == "yes" ) then
jhead -arw2 -ft -autorot -n p*.jpg
else
echo no Canon jpg files
endif
echo 'Checking *.JPG'
if ( `tcsh -f -c "ls -1 P*.JPG >& /dev/null" && echo yes` == "yes" ) then
jhead -aRW2 -ft -autorot -n P*.JPG
else
echo no Canon JPG files
endif
echo Setting permissions
chmod ugo=r Img*