A shell script for checking the last image and sending it in attachment to mail

Hello every one.

I use mutt :

"mpack -s "Test" /home/pi/Pictures/2018-10-05_23_10_40.jpg   my_email_addres "

to send me a particular picture with the name of the data+jpg in a pictures folder, but this folder I use it for a timelapse proyect with more pictures , and what I need is a bash script to checking the last image and sending it in attachment to my mail once a day by a cron:

00 12 * * * *   pi  sh  /home/pi/email_last_picture.sh

Thank You

Hello, what have you tried? :slight_smile:

Here are some pointers to help you get started:

  1. ls -rt | tail -1 to get the last image.
  2. Check if it's an image file (and not a dir or symlink, for instance)
  3. Email it as attachment.

Hope this helps.

Yes ,whith this code apearsrs last picture file on terminal. Now I need to send it to email it to my self. Thank you