Created
August 17, 2023 15:05
-
-
Save danielsuo/67c88b8ab976c845f7e866f76c53ed16 to your computer and use it in GitHub Desktop.
photo dump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ "$#" -ne 2 ]; then | |
echo "Usage: photo_dump.sh [SRC] [DST]" | |
fi | |
find $(realpath $1) -type f | grep -iE "(CR3|ARW|DNG|RAF|HEIC|JPG|JPEG|MOV|MP4)$" | while read SRC | |
do | |
DATE=`exiftool "$SRC" | grep "Create Date" | head -n 1 | tr -s " " | cut -d " " -f 4` | |
YEAR=`echo $DATE | cut -d ":" -f 1` | |
MONTH=`echo $DATE | cut -d ":" -f 2` | |
DAY=`echo $DATE | cut -d ":" -f 3` | |
FILENAME=$(basename "$SRC") | |
DST=$(realpath $2)/Photos/$YEAR/$MONTH/$DAY | |
if [[ "$FILENAME" == *.mov || "$FILENAME" == *.MOV || "$FILENAME" == *.mp4 || "$FILENAME" == *.MP4 ]]; then | |
DST=$(realpath $2)/Videos/$YEAR/$MONTH/$DAY | |
fi | |
mkdir -p "$DST" | |
mv "$SRC" "$DST/$FILENAME" | |
echo "Moved from $SRC to $DST/$FILENAME" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment