#!/bin/bash #Get the pics #set -x DIR=~/wallpaper/to_post MESSAGE=$DIR/newspost.txt NUM_PIC=24 #number of pictures to be posted # COUNTING : Counting and sorting files {{{ COUNTING () { find $DIR/t -name "*.jpg" >> $DIR/files.txt TOTAL=`wc -w < $DIR/files.txt` for COUNT in `seq 24` #35 do if [ $TOTAL = "0" ] then rm $DIR/files.txt exit fi FILE=`head -$((($RANDOM * 32678 +$RANDOM) % $TOTAL + 1)) $DIR/files.txt|tail -1|awk -F: '{print $NF}'` echo $FILE >> end_file.txt grep -v $FILE $DIR/files.txt > $DIR/files.txt.tmp mv $DIR/files.txt.tmp $DIR/files.txt let TOTAL=TOTAL-1 done rm $DIR/files.txt cat > $MESSAGE < /dev/null 2>&1` && MESSAGE } # /* }}} */ # MESSAGE : The Message itself{{{ MESSAGE () { cat >> $MESSAGE <