Размещение фотографий по дате съёмки с помощью Imagemagick и Bash

#!/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

Tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *