Skip to content

Instantly share code, notes, and snippets.

@goeland86
Created December 12, 2021 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goeland86/b95060b3b3f5d7331ff06bb57db871c7 to your computer and use it in GitHub Desktop.
Save goeland86/b95060b3b3f5d7331ff06bb57db871c7 to your computer and use it in GitHub Desktop.
Import script to sort out Canon CR3 camera files into the same import structure Shotwell does until CR3 support is merged in.
#!/bin/bash
if [[ $# -ne 2 ]]; then
echo "This script expects 2 arguments: "
echo " - the import folder, where images to import are located"
echo " - the target folder, where images to import should be stored"
echo "Your current execution provides neither."
exit 1
fi
IMPORT_BASE=$1
TARGET_BASE=$2
IMAGE_LIST=(`find ${IMPORT_BASE} | grep -i -E 'CR3|CR2|JPEG|JPG|MOV'`)
for image in "${IMAGE_LIST[@]}"; do
path=$(date -r ${image} '+%Y/%m/%d')
if [[ ! -d "${TARGET_BASE}/${path}" ]]; then
mkdir -p "${TARGET_BASE}/${path}"
fi
filename=$(basename $image)
echo "copying $image to ${TARGET_BASE}/${path}/${filename}"
cp ${image} ${TARGET_BASE}/${path}/${filename}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment