Organize your pictures by EXIF tags with bash
Just a simple script to order your thousands of pictures by putting them in subdirectories on the basis of EXIF shot date:
#!/bin/bash
# BashButler 1.0 - 11/2007 by Eugenio Rustico
# Bash script to organize your pictures in folders by date
#
# GPL v3 license http://www.gnu.org/licenses/gpl-3.0.html
ls -1 *.jpg | while read fn
do
export dt=`exiv2 "$fn" | grep timestamp | awk '{ print $4 }' | tr ":" "-"`
if test ! -e ./$dt
then
mkdir $dt
fi
mv "$fn" ./$dt
echo File "$fn" moved in "$dt"
done
echo Good job!
I wrote it to setup 4.900 pictures which were all in the same directory, and it was really fast and useful. My unstoppable sense of humor conceived this amazing script name: Bash Butler. I'm very sorry for this. =)
Notes:
- Of course you need exiv2 package on your system, but you can use other cli exif tools by modifying only one row;
- With very little changes, you can modify the script to organize your pictures by different EXIF tags (e.g. different folders for different digital cameras);
- Filenames with spaces are treated correctly;
- By default mv does'nt overwrite destination files: so all remaining files in current directory are copies, and can be deleted.