My public website https://www.chameth.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

import-photos.sh 832B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. SOURCE=~/Dropbox/photos-site
  3. TEMPLATE='---
  4. album_title: XXX
  5. album_date: YYY
  6. date: YYYY-MM-DD
  7. title: Photos of XXX — YYY
  8. url: /photos/$foldername/
  9. photos:
  10. $PHOTOS
  11. ---'
  12. PHOTO_PRINTF='- file: %f\n alt: Unknown\n caption: Unknown\n'
  13. for folder in $SOURCE/*; do
  14. foldername=${folder##*/}
  15. mkdir -p site/static/photos/$foldername
  16. for file in $folder/*; do
  17. filename=${file##*/}
  18. out="site/static/photos/$foldername/$filename";
  19. test -e "$out" || convert -thumbnail 400^ -gravity center -crop 400x200+0+0 -strip -quality 86 "$file" "$out";
  20. done
  21. if [ ! -e "site/content/photos/$foldername.md" ]; then
  22. export PHOTOS=$(find "site/static/photos/$foldername" -type f -printf "$PHOTO_PRINTF")
  23. envsubst <<< "$TEMPLATE" > "site/content/photos/$foldername.md"
  24. fi
  25. done