Guest User

Untitled

a guest
Jul 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # This script is used to copy images files from a connected volume to a local
  4. # directory.
  5. #
  6. # - Creates a folder with today's date in $PHOTO_DIR
  7. # - Moves RAW files into the root $PHOTO_DIR
  8. # - Creates a folder for JPEG images
  9. # - Creates a folder for edits/exports
  10. # - Creates a README file
  11.  
  12. # Example folder layout:
  13. #
  14. # /Users/bdw/Pictures/20180722/
  15. # ├── DSCF0266.RAF
  16. # ├── DSCF0267.RAF
  17. # ├── DSCF0268.RAF
  18. # ├── README.md
  19. # ├── _edits
  20. # └── _jpeg
  21. # ├── DSCF0266.JPG
  22. # ├── DSCF0267.JPG
  23. # ├── DSCF0268.JPG
  24. #
  25. set -e
  26.  
  27. # Configuration
  28. IMPORT_DEVICE=/Volumes/Untitled
  29. PHOTO_DIR=/Users/bdw/Pictures
  30. COPY_OR_MOVE_FILES=mv
  31. DATE_FMT="+%Y%m%d"
  32. EDITOR=vi
  33.  
  34. DATE=$(date "${DATE_FMT}")
  35. IMPORT_DIR="${PHOTO_DIR}/${DATE}"
  36. JPEG_DIR="${IMPORT_DIR}/_jpeg"
  37. EDITS_DIR="${IMPORT_DIR}/_edits"
  38. README="${IMPORT_DIR}/README.md"
  39.  
  40. # 1. Setup folder structure
  41. if [ ! -d "${IMPORT_DIR}" ]; then
  42. mkdir "${IMPORT_DIR}" && cat <<EOF > ${README}
  43. Location:
  44. Description:
  45. EOF
  46. sleep .2
  47. echo "--> Created directory ${IMPORT_DIR}"
  48. fi
  49.  
  50. if [ ! -d "${JPEG_FOLDER}" ]; then
  51. mkdir "${JPEG_FOLDER}"
  52. fi
  53.  
  54. if [ ! -d "${EDITS_FOLDER}" ]; then
  55. mkdir "${EDITS_FOLDER}"
  56. fi
  57.  
  58. # 2. Fill out the README with description, etc
  59. "${EDITOR}" "${README}"
  60.  
  61. # 3. Copy or move the photos
  62. import_raw() {
  63. find "${IMPORT_DEVICE}/DCIM" -name "*.RAF" -type f -exec "${COPY_OR_MOVE_FILES}" {} "${IMPORT_DIR}" \;
  64. }
  65.  
  66. import_jpg() {
  67. find "${IMPORT_DEVICE}/DCIM" -name "*.JPG" -type f -exec "${COPY_OR_MOVE_FILES}" {} "${JPEG_FOLDER}" \;
  68. }
  69.  
  70. import_jpg && import_raw
Add Comment
Please, Sign In to add comment