×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Bash
Posted by: Massimo Zappino
Added: Feb 7, 2015 9:49 PM
Modified: Aug 11, 2017 2:34 PM
Views: 16
  1. #!/bin/bash
  2. CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  3.  
  4. JPG_DIRECTORY="${CURRENT_DIR}/jpg"
  5. WATERMARK_DIRECTORY="${CURRENT_DIR}/watermark"
  6.  
  7. mkdir -p "${WATERMARK_DIRECTORY}"
  8.  
  9.  
  10. cd "${JPG_DIRECTORY}"
  11. for file in *.jpg
  12. do
  13.  date_string=`stat -c %y% "$file" | cut -d ' ' -f1`
  14.  year=`echo "$date_string" | cut -d '-' -f1`
  15.  month=`echo "$date_string" | cut -d '-' -f2`
  16.  day=`echo "$date_string" | cut -d '-' -f3`
  17.  dir_path="${year}/${month}/${day}";
  18.  today=`date +"%Y/%m/%d"`
  19.  if [ $dir_path = $today ]; then
  20.    echo $file today skipped
  21.    continue
  22.  fi
  23.  
  24.  echo -n "$file "
  25.  MESSAGE=`stat -c %y% "$file" | cut -d '.' -f1`
  26.  echo "$MESSAGE"
  27.  convert "$file" -fill white -stroke black -pointsize 20 -draw "gravity southeast fill white stroke black text 5,5 '${MESSAGE}'" ${WATERMARK_DIRECTORY}/"$file"
  28.  if [ "$?" == "0" ]; then
  29.    rm "$file"
  30.  else
  31.    echo "ERROR making video"
  32.  fi
  33. done
  34.  
  35.