=== Update 11/2013 ==
Sooo, I found that the below script didn’t do really what I wanted and I got a lot of files from 2012 in 2013 folders. So I’ve changed it around to use stat and maybe exif data in the future:
function rsyncFile()
{
for img in ${PATH}/*
do
echo “${img}”
ymd=`${STAT} -c %y “${img}” | ${CUT} -d’ ‘ -f1 | ${SED} -e ‘s/-/./g’`
year=`echo ${ymd} | ${AWK} -F. ‘{print $1}’`
month=`echo ${ymd} | ${AWK} -F. ‘{print $2}’`
day=`echo ${ymd} | ${AWK} -F. ‘{print $3}’`
picturesPath=/home/ryan/Pictures/${year}.${month}/${year}.${month}.${day}
${MKDIR} -p ${picturesPath}
echo ${RSYNC} -av “${img}” ${picturesPath}
${RSYNC} -av “${img}” ${picturesPath}
done
}
== End Update
Here’s a quick bash script I wrote to copy stuff from my camera memory card to my Pictures directory but so that it will create it in the format that I like:
/home/user/Pictures/year.twodigitmonth/year.twodigitmonth.twodigitday
So Feb 1st, 2013 pictures would be in directory:
/home/user/Pictures/2013.02/2013.02.01
The script is really just a function that takes 3 arguments, the month in ls format, the two digit representation of the month, and the year:
#!/bin/bash PATH=/media/Canon_DIGITAL/DCIM/100CANON/ PICTURES=/home/user/Pictures MONTHS="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec" AWK=/usr/bin/awk GREP=/bin/grep LS=/bin/ls MKDIR=/bin/mkdir RSYNC=/usr/bin/rsync function rsyncMonth() { month=${1} numonth=${2} year=${3} echo $month $numonth $year for img in `${LS} -l ${PATH} |${GREP} ${month}|${AWK} '{print $NF}'` do day=`${LS} -ld ${PATH}/${img} | ${AWK} '{print $7}'` if [ ${day} -lt 10 ] then day="0${day}" fi picturesPath=${PICTURES}/${year}.${numonth}/${year}.${numonth}.${day} ${MKDIR} -p ${picturesPath} ${RSYNC} -av ${PATH}/${img} ${picturesPath} done }
and you would call it below the function like:
rsyncMonth Jan 01 2013
to get all the pictures off the memory card that match January 2013.