Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # This script is used to copy images files from a connected volume to a local
- # directory.
- #
- # - Creates a folder with today's date in $PHOTO_DIR
- # - Moves RAW files into the root $PHOTO_DIR
- # - Creates a folder for JPEG images
- # - Creates a folder for edits/exports
- # - Creates a README file
- # Example folder layout:
- #
- # /Users/bdw/Pictures/20180722/
- # ├── DSCF0266.RAF
- # ├── DSCF0267.RAF
- # ├── DSCF0268.RAF
- # ├── README.md
- # ├── _edits
- # └── _jpeg
- # ├── DSCF0266.JPG
- # ├── DSCF0267.JPG
- # ├── DSCF0268.JPG
- #
- set -e
- # Configuration
- IMPORT_DEVICE=/Volumes/Untitled
- PHOTO_DIR=/Users/bdw/Pictures
- COPY_OR_MOVE_FILES=mv
- DATE_FMT="+%Y%m%d"
- EDITOR=vi
- DATE=$(date "${DATE_FMT}")
- IMPORT_DIR="${PHOTO_DIR}/${DATE}"
- JPEG_DIR="${IMPORT_DIR}/_jpeg"
- EDITS_DIR="${IMPORT_DIR}/_edits"
- README="${IMPORT_DIR}/README.md"
- # 1. Setup folder structure
- if [ ! -d "${IMPORT_DIR}" ]; then
- mkdir "${IMPORT_DIR}" && cat <<EOF > ${README}
- Location:
- Description:
- EOF
- sleep .2
- echo "--> Created directory ${IMPORT_DIR}"
- fi
- if [ ! -d "${JPEG_FOLDER}" ]; then
- mkdir "${JPEG_FOLDER}"
- fi
- if [ ! -d "${EDITS_FOLDER}" ]; then
- mkdir "${EDITS_FOLDER}"
- fi
- # 2. Fill out the README with description, etc
- "${EDITOR}" "${README}"
- # 3. Copy or move the photos
- import_raw() {
- find "${IMPORT_DEVICE}/DCIM" -name "*.RAF" -type f -exec "${COPY_OR_MOVE_FILES}" {} "${IMPORT_DIR}" \;
- }
- import_jpg() {
- find "${IMPORT_DEVICE}/DCIM" -name "*.JPG" -type f -exec "${COPY_OR_MOVE_FILES}" {} "${JPEG_FOLDER}" \;
- }
- import_jpg && import_raw
Add Comment
Please, Sign In to add comment