Skip to content

Instantly share code, notes, and snippets.

@rickard2
Created September 17, 2012 16:27
Show Gist options
  • Save rickard2/3738318 to your computer and use it in GitHub Desktop.
Save rickard2/3738318 to your computer and use it in GitHub Desktop.
Image copy
#!/bin/bash
if [ -z $1 ]; then
echo "Usage: $0 /path/to/destination/folder"
exit 1
fi
BASE=$1
for x in `find . -iname "*jpg"`; do
DATE=`exif $x 2>/dev/null | grep -i "date and time" | head -1 | sed -e 's/|/ /g' | awk {'print $5'}`
if [ -z "$DATE" ]; then
echo "$x: No date available in EXIF header"
else
FOLDER=`echo $DATE | sed -e 's/:/\//g' | cut -c 1-7`
FOLDER=$BASE$FOLDER/
mkdir -p $FOLDER
cp -v $x $FOLDER
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment