#!/bin/bash
# Goes through all jpeg files in current directory, grabs date from each
# and sorts them into subdirectories according to the date
# Creates subdirectories corresponding to the dates as necessary.
# Moves mov files by file creation date.
# sudo apt-get install imagemagick
for fil in *.JPG
do
datepath="$(identify -verbose $fil | grep DateTimeOri | awk '{print $2 }' | sed s%:%%g)"
if ! test -e "$datepath"; then
mkdir -pv "$datepath"
fi
mv -v $fil $datepath
done
for mov in *.MOV
do
datepath="$(stat $mov | grep Modify | awk '{print $2}' | sed s%-%%g)"
if ! test -e "$datepath"; then
mkdir -pv "$datepath"
fi
mv -v $mov $datepath
done
Credits: linuxjournal