I have a bash script that I am using for a photography project that I have been working on. In short, I have a Raspberry Pi camera taking pictures of a sunrise everyday. It takes those pictures and compresses them into a movie and uploads it to my Dropbox account. Then I have another Raspberry Pi at home that downloads the movies, and turns them back into still pictures. I am using the program Image Magick to make a montage of those pictures so they layout in a nice grid. It should be pretty beautiful when its done.
The problem is that my bash script is pretty inefficient, and it requires a lot of work to prepare it. My limited programming knowledge is an obstacle here. My script is posted below.
The photos are in folders labeled by date (YYYYMMDD) and the photos themselves are labeled by date and sequenced (YYYYMMDD-0001.jpg, YYYYMMDD-0002.jpg, etc). There are 1440 pictures in each folder.
I have a for loop that goes through each folder that I identify as a variable. I would prefer to have a for loop that finds every folder in a range of dates (20151001 - 20161001). Is there a more efficient way to write this? I have poked around for something, but I haven't had a lot of luck.
Any help would be greatly appreciated!
DA="20151001/20151001-"; DB="20151002/20151002-"; DC="20151003/20151003-"; DD="20151004/20151004-"; DE="20151005/20151005-"; DF="20151006/20151006-"; DG="20151007/20151007-"; DH="20151008/20151008-"; DI="20151009/20151009-"; DJ="20151010/20151010-"; DK="20151011/20151011-"; DL="20151012/20151012-"; DM="20151013/20151013-"; DN="20151014/20151014-"; DO="20151015/20151015-"; DP="20151016/20151016-"; DQ="20151017/20151017-"; DR="20151018/20151018-"; DS="20151019/20151019-"; DT="20151020/20151020-"; # for four digit numbers with leading zeroes, counter needs to start as five di$ # then remove the left most digit. counter=10000 for f in ${DA}*.jpg; do let "counter+=1" #Image Magick Montage lays the pictures out in a 10X2 grid. montage -tile 10x2 -geometry +1+1 ${DA}${counter:1}.jpg ${DB}${counter:1}.jpg ${DC}${counter:1}.jpg ${DD}${counter:1}.jpg ${DE}${counter:1}.jpg ${DF}${counter:1}.jpg ${DG}${counter:1}.jpg ${DH}${counter:1}.jpg ${DI}${counter:1}.jpg ${DJ}${counter:1}.jpg ${DK}${counter:1}.jpg ${DL}${counter:1}.jpg ${DM}${counter:1}.jpg ${DN}${counter:1}.jpg ${DO}${counter:1}.jpg ${DP}${counter:1}.jpg ${DQ}${counter:1}.jpg ${DR}${counter:1}.jpg ${DS}${counter:1}.jpg ${DT}${counter:1}.jpg /media/KINGSTON/montage${counter:1}.jpg done